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

Ulid Data truncated for column 'metable_id' #26

Closed
Grazulex opened this issue Dec 17, 2023 · 9 comments · Fixed by #31
Closed

Ulid Data truncated for column 'metable_id' #26

Grazulex opened this issue Dec 17, 2023 · 9 comments · Fixed by #31
Assignees
Labels
enhancement New feature or request released

Comments

@Grazulex
Copy link

Hello,

The primary key of my model is a ulid type and when a try to insert metas I have this error :

" SQLSTATE[01000]: Warning: 1265 Data truncated for column 'metable_id' at row 1 (Connection: mysql, SQL: insert into meta (key, type, value, published_at, metable_id, metable_type, updated_at, created_at) values (color, integer, 87, 2023-12-17 07:12:59, 01hhv9xdt2nbx12zgffb76vpy8, App\Models\Item, 2023-12-17 07:12:59, 2023-12-17 07:12:59))"

Can I change something to use ulid and not id ?

Thanks you

@Grazulex
Copy link
Author

temporaly, I have change your migration file to

$table->ulidMorphs('metable');

@marijoo
Copy link
Member

marijoo commented Dec 17, 2023

Will have a look at this, thanks.

@marijoo
Copy link
Member

marijoo commented Dec 17, 2023

I think what you did (changing the migration file) is the way to go. Or do you have another recommendation?

Just checked how this problem is handled in another package: https://spatie.be/docs/laravel-permission/v6/advanced-usage/uuid

@Grazulex
Copy link
Author

The best would have been to have the choice of morph type during installation but I don't know how to do that.
I propose to make a merge request to update Readme file to indicate the procedure to follow to create a local migration file for the use of UUID, ULID,...

@Grazulex
Copy link
Author

see #27

@marijoo
Copy link
Member

marijoo commented Dec 18, 2023

I’m thinking about having this configurable. So one would have to publish the config before migration, choose between numeric ids or UUID/ULID and then the migration would take this into account. What do you think?

@Grazulex
Copy link
Author

idd...that will be beter...in the config file have a option to choice beteween ids (default) or uuid or ulid and when you run the migration, choice the good morph type link to the config.

Do you want that I try to do it ?

@marijoo
Copy link
Member

marijoo commented Dec 18, 2023

Would happily accept a PR for that, yes. But please add test cases for having uuid or ulid enabled. :)

Otherwise I may will find the time towards the end of the week.

@marijoo marijoo added the enhancement New feature or request label Dec 18, 2023
marijoo added a commit that referenced this issue Jan 24, 2024
marijoo added a commit that referenced this issue Jan 24, 2024
* feat: add support for `uuid` and `ulid` primary keys

resolves #26

* ci: reduce tests run by morph type

* fix: add support for uuid and ulid in Laravel 9

* docs: update section about uuid and ulid support

* Fix styling [skip-ci]

* fix: make sure string was passed

* ci: reduce tests run by morph type

---------

Co-authored-by: marijoo <marijoo@users.noreply.github.com>
@marijoo
Copy link
Member

marijoo commented Jan 24, 2024

🎉 This issue has been resolved in version 1.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Development

Successfully merging a pull request may close this issue.

2 participants