I don't think there is any reason you cant just call the seeder from the migration.
Run seeds with migrations together without truncating all tables.
Hi friends,
I have a problem/doubt. In my Laravel application I have several migrations and seeders. Now, I created one migration and his corrresponding seeder. When I launched the migration I would run only the seeder created. Like having in the up() method of the migration: insert + run seeder. I want 'associate' migrations with seeders to initial data loads automatically each migration without truncating all tables.
It's posibble?
Thank you very much for your time and answers.
If you need the to seed after a migration then that seed is part of the migration and should be fired by the migration itself.
note that you can specify a specific seeder class when you run php artisan db:seed --class=NewDataSeeder
public function up()
{
//schema migrations here
//now the data migration
Artisan::call('db:seed', [
'--class' => MigrationSpecificSeeder::class,
]);
}
Please or to participate in this conversation.