laravel-permission: PermissionAlreadyExists - A `users_manage` permission already exists for guard `web`.
I reset my database and deleted all the tables. When I rerun the migration with the seeders I get an error that a permission already exists. php artisan migrate:reset
runs fine but does not fix the error. How can I reseed the database and start fresh? Thank you
php artisan migrate --seed
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrating: 2017_07_12_145959_create_permission_tables
Migrated: 2017_07_12_145959_create_permission_tables
Migrating: 2017_07_12_230054_create_products_table
Migrated: 2017_07_12_230054_create_products_table
Seeding: PermissionSeed
[Spatie\Permission\Exceptions\PermissionAlreadyExists]
A `users_manage` permission already exists for guard `web`.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16
I had to clear the permission cache!
Running:
Got me going again! Thank you
https://github.com/spatie/laravel-permission/issues/231
Help for me:
sudo php artisan cache:forget spatie.permission.cache && sudo php artisan cache:clear
sudo chmod 777 -R /var/www/html/project/storage/
Try
php artisan migrate:refresh --seed
. Also ensure in yourPermissionSeed
that you are ONLY defining one instance ofusers_manage
. Let me know how it goes!OR you can paste your
PermissionSeed
here so we can see if the problem is in there.😃
php artisan cache:forget spatie.permission.cache php artisan cache:clear
Same issue on Laravel 7.1X when I tried to refresh the migrations, and this worked for me:
Better to use
php artisan permission:cache-reset
as documented https://docs.spatie.be/laravel-permission/v3/advanced-usage/cache/Besides the clearing of the cache and all that, try to check if permissions and roles already exist. This way you can run your seeder as often as you like without errors … even extend it and rerun it, if you forgot something 😉
and
and