The obvious way to apply specific seeds rather than seeding everything is by using the --class
flag:
php artisan db:seed --class[=CLASS]
Is there a way to track which seeders have been applied so far in Laravel (say, the same way you can track how migrations got applied by running php artisan migrate:status
)?
Further, is there a way to apply a range of seeders (rather than specifying each class individually, which is very cumbersome).
What made me think about this is this part in a seeder in the book "Build APIs You Won't Hate":
28 foreach ($tables as $table) {
29 DB::table($table)->truncate();
30 }
31
32 $this->call('MerchantTableSeeder');
33 $this->call('PlaceTableSeeder');
34 $this->call('UserTableSeeder');”
The idea is that every time you want to run the main seeder, you must start from a clean slate. But that's not practical for us in our staging environment at least which will always have a combination of seeding data and manual data entered by our QA/Operations staff.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…