assignRole and syncRoles fail for model with ulid type id
francisnnumbi opened this issue · 1 comments
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 intomodel_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
!
But when I decide to change the type to string
, it works fine, like here.
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 ?
Are there some parts of this article in the documentation that may help? https://spatie.be/docs/laravel-permission/v6/advanced-usage/uuid