Open qsona opened 8 years ago
Yes, foreign key constraint consideration would be nice. Working around it myself.
Disabling referential integrity during seeding is a workaround for some situations, but note postgresql (and I'm assuming other dbs) will not validate the constraints afterward, so you can end up with orphaned foreign keys:
ActiveRecord::Base.connection.disable_referential_integrity do
SeedFu.seed
end
If
table_a
hastable_b_id
column, and the foreign key constraint exists,seed_fu
tries to insert initialtable_a
data and fails because of the constraint.As far as I know, seed_fu reads files in alphabetical order of filenames. So I can change the filenames into
db/fixtures/01_table_b.rb
anddb/fixtures/02_table_a.rb
to fix it, but I think it's better if we need not do it. Is there any solution? Thanks.