I've setup my migration files and my seeder files with fake data and they're working nicely. I'm about to commit my work but don't really know what to do with my seeder files. I definitely don't want to run seeder files in production, so I thought I would ignore them. I wouldn't want to accidently migrate and seed fake data into production!
Yet, I'm thinking seeders can be used in production with real data. Say I add a new column that must perform some calculation on the other table columns (for the sake of the example let us ignore that any field that can be calculated from other fields shouldn't exist in the database) and store a value. Or a new setting/flag. I think I could create a seeder to populate that field with the already existing production data. So now I can't ignore the seeder directory.
Should I decide on ignoring each file independently for every case? Can I declare somewhere that the seeder should only run in dev
environment? What is the convention here?
No. Seed files should be part of your repo. Of course you shouldn't run them in production, but a developer checking your code out should be able to migrate and seed their database with dummy data. They can't very well do that if you've gitignore-d the directory contents.