seed_dump
seed_dump copied to clipboard
Breaks validations for associations
I've got a database with Games, Ratings, and Users, and naturally the Ratings validate that both their User and their Game exist. By default, the seed dump breaks this by putting everything into the file in alphabetical order. Could you add an option for specifying order?
I got the same question, hopefully this can be fixed. thank you.
Instead of specifying order, you could skip the validations. This seems like a tricky problem because of circular dependencies, especially if you have a presence validator that's dependent on a certain condition. https://github.com/werkshy/seed_dump/commit/96c98fe3ab71bdff7fd056864253d61d9de37010 This introduces what you would need for that, at least.
I could do that, but it would be dumb, because I do actually need the objects to be valid.
I would like an option like this too. :+1:
SeedDump.dump(order: [User, Comment, Post])
You can force a dump order by being explicit in the ENV['MODELS']
. It just will not handle missing models or splats.
task :dump => :environment do
ENV['MODELS'] ||= "Product, Contact, ProductVersion, Owner"
SeedDump.dump_using_environment(ENV)
end
I believe this is the same issue as #83. Pull request submitted.