I've got some seeders for precisely this purpose.
This is a pretty basic example, but it ensures these small handful of countries get populated into the DB on initial db:seed, and since it uses firstOrCreate they're only created once.. this way I can run db:seed as part of my deploy and not worry about issues despite the fact that I've got a few different seeders. firstOrCreate ensures the seed only does anything if the entry doesn't already exist.
<?php
use App\Models\Country;
use Illuminate\Database\Seeder;
class CountriesTableSeeder extends Seeder
{
private $countries = ['USA', 'Bulgaria', 'Serbia', 'Ukraine', 'UK', 'Turkey'];
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
foreach ($this->countries as $country) {
Country::firstOrCreate(['name' => $country]);
}
}
}
I have a couple others that are a bit more complex, but the general approach is the same. I think it works exactly as I'd like it to.. migrations -- to my mind -- are for table structure, not table content.