# Move data with migration

**URL:** <https://www.ruby-forum.com/t/move-data-with-migration/155836>\
**Category:** Rails\
**Created:** [December 17, 2008, 11:00am UTC](https://www.ruby-forum.com/t/move-data-with-migration/155836 "2008-12-17T11:00:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [December 17, 2008, 11:00am UTC](https://www.ruby-forum.com/t/move-data-with-migration/155836/1 "2008-12-17T11:00:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [December 17, 2008, 3:19pm UTC](https://www.ruby-forum.com/t/move-data-with-migration/155836/2 "2008-12-17T15:19:44Z")

</div>

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.
