Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KodaC's avatar
Level 1

Update Seeder (Spatie Permission) and run only in test environment

I add my permissions via a seeder:

Permission::create(['name' => 'user_view']);
Permission::create(['name' => 'user_create']);
Permission::create(['name' => 'user_edit']);
Role::create([
    'name' => 'admin'
])->givePermissionTo([
    'user_view',
    'user_create',
    'user_edit',
]);

During the first installation or during a test, I create the tables with php artisan migrate:(re)fresh --seed

But now I have two questions and hope you can help me.

  1. if I now develop a new feature which requires new permissions and which I also want to add to the administrators or other group, how can I carry out the update in the productive environment so that it does not overwrite the existing users and permissions?

  2. in my seeder files I still create a lot of test entries. Is there a possibility that these test entries are only executed on my test system but not on my productive system with php artisan migrate:(re)fresh --seed?

0 likes
0 replies

Please or to participate in this conversation.