Move data with migration

Hi all,

I have to change my database structure for a new release.

I can change the database structure with migrations but I also want to
move the data from the old structure to the new structure. Is this
best done via a migration (if possible)?

Thanks
Stijn

A migration is probably the best way to approach this; you’ll be moving
your data programmatically as well as creating the new structure. If
possible, your ‘down’ method could put it all back the way it was as
well.

I did this recently, and following the create for the new tables, there
were a series of data steps within the migration to move data from the
old structure to the new. I cloned my live data to my dev envt to make
sure I handled all the existing cases. Then test, test, test.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs