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

assignRole and syncRoles fail for model with ulid type id #2593

Closed
francisnnumbi opened this issue Jan 19, 2024 · 2 comments
Closed

assignRole and syncRoles fail for model with ulid type id #2593

francisnnumbi opened this issue Jan 19, 2024 · 2 comments

Comments

@francisnnumbi
Copy link

When I create a users table with id of ulid type, I get an issue with assigning role or permission to user.

The error states that :

SQLSTATE[01000]: Warning: 1265 Data truncated for column 'model_id' at row 1 (SQL: insert into model_has_roles (model_id, model_ty pe, role_id) values (01hmhx0f95bbw2xg2t6vsxp65s, App\Models\User, 1))SQLSTATE[01000]: Warning: 1265 Data truncated for column 'model
_id' at row 1 (SQL: insert into model_has_roles (model_id, model_type, role_id) values (01hmhx0f9q43g7zf3mxeywn64x, App\Models
User, 2))

When I check the create_permission_tables migration, I notice for exemple, at create model_has_roles table, the model_morph_key is of type unsignedBigInteger !

image

But when I decide to change the type to string, it works fine, like here.
image

But I noticed at the same time, this issue is not there when using sqlite as database !

I know what I have done is a hack. Is there a better way of solving this issue ?

@drbyte
Copy link
Collaborator

drbyte commented Jan 20, 2024

Are there some parts of this article in the documentation that may help? https://spatie.be/docs/laravel-permission/v6/advanced-usage/uuid

@spatie-bot
Copy link

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

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