laravel-permission: [5.9.0] Artisan migrate throwing QueryException
After latest update to 5.9.0, php artisan migrate / migrate:fresh is throwing Query Exception.
SQLSTATE[42000]: Syntax error or access violation: 1166 Incorrect column name ‘’ (SQL: create table model_has_permissions
(`` bigint unsigned not null, model_type
varchar(255) not null, model_id
bigint unsigned not null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)
Laravel: 9.50.2 Permission package: 5.9.0 PHP: 8.1 DB: mariadb 10.5
Steps to reproduce the behavior:
- Create fresh Laravel App
- composer require spatie/laravel-permission
- Add HasRoles to User
- php artisan migrate -> Query Exception
When permissions package is locked to 5.8.0, no QueryException is thrown.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 23 (4 by maintainers)
Same here. Clearing cache and performing a fresh migration does not solve the issue. For now, pin the version to
5.8.0
and it will work fine again.v5.9.1 reverted the change.
Hi, can somebody test this commit on 5.9.0 https://github.com/erikn69/laravel-permission/commit/09088c00756bfd2d71bea3f4d6f67fccba895ba5, maybe that fix it
@AhmedMub perhaps @erikn69 solution might work for you.
I can confirm alongside @alfinauzikri That @erikn69 's solution works. I tested it on a fresh project using
5.9.0
. Great Job all around. @erikn69 I think a PR is warranted.@erikn69 you’re correct. The problem started after the last push to
spatie:main
2 hours agoSame issue noticed. There is nothing to clear in cache for permissions.
In migration file, the “PermissionRegistrar” class is not instantiated and hence its constructor is not being called & no value set for its static variable $pivotPermission. Hence the migration query showing a blank column name while creating table “model_has_permissions”
I confirm the same error here. Can’t run the package migration for 5.9.0.