Running seed files in particular order
See original GitHub issueI have a few seed files with inter dependencies. What are the best practices to make seed files run in a specific order, so I don’t get errors about failed foreign key constraints? Should I prefix them with numbers, i.e. 01_
, 02_
… or is there a better way? Thank you.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Running seed files in particular order · Issue #637 · knex/knex
Seeds are sorted by Array.prototype.sort so you can rely on alphabetical order. Your other option is to run seeds that have dependencies in...
Read more >specify execution order of seed files in rails - Stack Overflow
My approach overrides rake db:seed and runs timestamped seed files under the seed directory in chronological order just like migrations.
Read more >Rails run seeds in specific order (timestamp your seed files)
Many a times when you generate a model and create a seed file for it, you do so by initializing an empty seed...
Read more >Database seeding with Knex - DEV Community
Generally speaking, we should also keep seed files in order, because we may have seed files that rely on previous seeds for their...
Read more >Database: Seeding - The PHP Framework For Web Artisans
Laravel includes the ability to seed your database with data using seed classes. ... to run other seed classes, allowing you to control...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@orlando what about
knex seed:make $(date +%s)_UsersTableSeeder
That’s one option. Seeds are sorted by
Array.prototype.sort
so you can rely on alphabetical order. Your other option is to run seeds that have dependencies in a single file so you have full control over the control flow. Keep in mind that you can alwaysrequire
stuff from another folder (including json) to keep organized.