IMHO it would be a good idea to use a seeder and execute it manually after each installation on a server.
Feb 28, 2025
8
Level 3
Seed required production data, how?
I'm working on a project where I'll be having user roles.
Some specific roles should exist on production after deployment, for example "admin" and "guest". What's the proper way to insert this data?
Currently I have it inside the migrations file, inside the up() method right after the Schema:
DB::table('roles')->insert([
['name' => 'admin', 'description' => 'Administrator with full access'],
['name' => 'guest', 'description' => 'Guest user'],
]);
Buuuut... I know migrations are intended for structure and not data. I could also use a seeder and detect environment, but I'm not sure I fancy that approach either. Last option would of course be to manually insert the roles after deployment.
Anything I'm missing? Which approach is recommended?
Please or to participate in this conversation.