Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good idea to collapse old rails migrations?

A rails app I am developing currently has about 35 migrations up to this point. Since the application started as an experiment, there is a fair amount of meaningless churn in the migrations as I went back and forth between different ideas.

Are there any drawbacks to collapsing migrations 1-35 into one migration? I was planning to do this by having the first migration load the schema as it is now and deleting all the previous migrations.

I am currently the only person working on this project, if that makes a difference.

like image 350
Angela Avatar asked Apr 01 '09 19:04

Angela


1 Answers

If you have your code under source control (you do have your code under source control, don't you?) then I'd say there's no real harm, provided you accept that rolling back schema changes is going to require either restoration of old migrations or brand new migrations. Just be sure you understand the implications and accept them before setting anything in stone.

Your current schema.rb can form the basis of a new single migration that will start a new set.

Be warned that if you have data manipulation operations in your existing migrations, static data loads, for example, and/or possible subsequent transformations, then these will need to be handled somewhere. It's something I've tripped over a few times...

like image 95
Mike Woodhouse Avatar answered Oct 14 '22 11:10

Mike Woodhouse