# Data migrations coupled to the model code

**URL:** <https://www.ruby-forum.com/t/data-migrations-coupled-to-the-model-code/112004>\
**Category:** Rails\
**Created:** [August 14, 2007, 6:30am UTC](https://www.ruby-forum.com/t/data-migrations-coupled-to-the-model-code/112004 "2007-08-14T06:30:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [August 14, 2007, 6:30am UTC](https://www.ruby-forum.com/t/data-migrations-coupled-to-the-model-code/112004/1 "2007-08-14T06:30:49Z")

</div>

It seems to me that data migrations have a serious flaw when refactoring  
models and the database schema – they are coupled to the model class  
relationships.

If I’m trying to get _rid_ of old relationships in favor of new changes  
to the schema, I eliminate the ability to back down through previous  
data migrations, or even to drop the database and migrate from scratch.

Are there techniques for dealing with this? Should I be using something  
other than the model relationships in the data migration? Should I be  
checking respond\_to? in the migration? (In which case I would be forced  
to abandon data.)
