seed_dump icon indicating copy to clipboard operation
seed_dump copied to clipboard

Breaks validations for associations

Open jkopczyn opened this issue 9 years ago • 6 comments

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?

jkopczyn avatar Apr 13 '15 21:04 jkopczyn

I got the same question, hopefully this can be fixed. thank you.

yuft avatar May 26 '15 13:05 yuft

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.

hut8 avatar Oct 20 '15 21:10 hut8

I could do that, but it would be dumb, because I do actually need the objects to be valid.

jkopczyn avatar Oct 21 '15 04:10 jkopczyn

I would like an option like this too. :+1:

SeedDump.dump(order: [User, Comment, Post])

shadowbq avatar Feb 08 '16 18:02 shadowbq

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

shadowbq avatar Feb 23 '16 02:02 shadowbq

I believe this is the same issue as #83. Pull request submitted.

GarthSnyder avatar May 17 '16 23:05 GarthSnyder