Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

versionable_id as uuid #47

Closed
alex-mcarrow opened this issue Apr 19, 2023 · 3 comments
Closed

versionable_id as uuid #47

alex-mcarrow opened this issue Apr 19, 2023 · 3 comments

Comments

@alex-mcarrow
Copy link

versionable_id throw error because id is UUID:

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'versionable_id' at row 1 (Connection: mysql, SQL: insert into versions (versionable_id, versionable_type, user_id, contents, updated_at, created_at) values (98f5f55d-00f6-4577-8e1f-782526c17c27, App\Models\Contact, 1, {"last_name":"\u0439\u0446\u0443\u043ag1","updated_at":"2023-04-19T11:53:18.000000Z"}, 2023-04-19 14:53:18, 2023-04-19 14:53:18))

@overtrue
Copy link
Owner

@alex-mcarrow If you want to support the uuid format, you need to change the versionable_id field to the corresponding format:

php artisan vendor:publish --provider="Overtrue\LaravelVersionable\ServiceProvider" --tag=migrations

Then change it to:

database/migrations/2019_05_31_042934_create_versions_table.php

-$table->morphs('versionable');
 $table->uuidMorphs('versionable');

Then run migrate command:

PHP artisan migrate

@tonypartridge
Copy link

Yep FYI I did this a few months ago and it's been fine. @overtrue it might be an idea to chuck it as a config option prior to migration?

@overtrue
Copy link
Owner

Good idea, I will add this feature in a few days, or feel free to make a PR. Thanks.

overtrue added a commit that referenced this issue Mar 8, 2024
@overtrue overtrue closed this as completed Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants