How to import data with many associations?
I have an upcoming situation where I'll be importing a lot of data with many associations into a Rails app. The data will show the links between the objects using the original native database IDs.
When I import the data (not sure how I'll do it yet, probably CSV) what would be a good way to set up the correct associations?
I'm thinking of writing the original IDs of each object to an
old_id column and using that somehow to create the associations in the database.
I'm concerned about the depth of associations here. Less than a dozen objects but all heavily associated to each other.
Any thoughts? Have I explained this well enough?
You can specify the column on your association that's used for joining tables. You'd just specify that
old_id column and you should be good to go.
Chris - how will this work with the associations already set up in the app?
Create new ones like
has_many :old_associations, foreign_key: :old_id or whatever options are necessary.