[Feature Request] Allow loading of multiple seed files

I think it would be beneficial to loop over the array of paths in paths[“db/seeds.rb”] instead of just grabbing the first one and loading it. Might be good to rename it"db/seeds" and prefill it with “db/seed.rb” then.

This would especially be helpful in engines that already add migrations. Right now this can still be achieved by hooking into the rake task but it’s not as great (either runs after the app’s seeds that may be dependent on it or it runs before the whole task, missing the abort_if_pending_migrations check which loads the environment and config).

If this is something you’d be interested in, I can create a pull request!





You can use db/seeds.rb as an entry point to load more seeds files:

# db/seeds.rb

load "./seeds/admin_seeds"

load "./seeds/customer_seeds"

load "./seeds/more_seeds"

You can also set your own seed loader: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/tasks/database_tasks.rb#L270-L272

Thanks Kir, I’ve looked into that a bit and it seems like it’d help from the application perspective, but coming from a gem, you still wouldn’t be able to hook into the application’s seed loading process.