simultaneous migrations

Courtenay : December 7th, 2006

If you do a lot of branch work, or mirror a remote repository, you'll always be clashing migration numbers. No more! I've written a patch to migration code so you can have multiple migrations with the same number. This means that these migrations can effectively be run in parallel, so long as all the migrations with that number have the IndependentMigration class. There are a number of caveats, but nothing too crazy. 1. you're at #48 and you merge in a branch where there are two #32. Your future migrations fail since not all #32 are Independent Migrations. Edit the offending #32, migrate down, migrate back up. You'll need to temporarily comment out your own #32 and the existing #32 down method, so you can run them properly. This is painful, but too much magic means you destroy your database. 2. you're at #55 and someone merges another #55 into your branch. Easy, just change the class of both files to IndependentMigration. The patch is here: http://dev.rubyonrails.org/ticket/6799

6 Responses to “simultaneous migrations”

  1. François Beausoleil Says:

    Hello courtenay. Interesting solution. I have another solution: http://blog.teksol.info/articles/2006/12/08/migrations-branches-and-dependencies

    I’ll post some code this afternoon.

  2. Scott Burton Says:

    Cortenay, howsit goin? I just ran into this same problem the other day. My solution was to yell out loud “Migrations in branches SUCK!” Yours is much cleaner ;)

  3. Dayne Broderson Says:

    If you are on #48 and you have to migrate down to #31 to apply the new #32…. wouldn’t you want to comment out all the ‘down’ methods for migrations #32 all the way through #48 so you don’t lose stuff when you head back on up to #48 again?

  4. Dayne Broderson Says:

    If you are on #48 and you have to migrate down to #31 to apply the new #32…. wouldn’t you want to comment out all the ‘down’ methods for migrations #32 all the way through #48 so you don’t lose stuff when you head back on up to #48 again?

  5. Dayne Broderson Says:

    doh, hate it when I don’t notice the AJAX magic.

  6. chumbawumba Says:

    Hi, really like your site. Just got a question, does anybody know where I can buy software called Mototools 6 from? It’s used for unlocking Motorola phones with the IMEI, and I really need it, as I don’t have a cable to link my phone to my PC. Please help!

Sorry, comments are closed for this article.