![]() |
Articles Feed |
Categories
Archives
- July 2010 (5)
- June 2010 (4)
- April 2010 (3)
- March 2010 (2)
- February 2010 (2)
- January 2010 (1)
- December 2009 (1)
- October 2009 (2)
- September 2009 (2)
- August 2009 (1)
- July 2009 (5)
- June 2009 (2)
- May 2009 (2)
- April 2009 (8)
- March 2009 (7)
- January 2009 (2)
- December 2008 (3)
- November 2008 (5)
- October 2008 (4)
- September 2008 (6)
- August 2008 (4)
- July 2008 (5)
- June 2008 (5)
- May 2008 (4)
- April 2008 (2)
- February 2008 (4)
- January 2008 (2)
- December 2007 (2)
- November 2007 (2)
- October 2007 (2)
- September 2007 (1)
- August 2007 (3)
- July 2007 (1)
- June 2007 (4)
- May 2007 (7)
- April 2007 (2)
- February 2007 (3)
- January 2007 (3)
- November 2006 (3)
- October 2006 (3)
- September 2006 (17)
- November 2004 (1)
Rails Migrations and Subversion
by: paul | September 28th, 2006 |
In rails, migrations are generated like so
paul-pagels-computer:~/RailsProjects/project paulpagel$ ruby script/generate migration CreatePacketTimestamp exists db/migrate create db/migrate/013createpacket_timestamp.rb
This creates a numbered migration with an up and a down schema direction. This has been incredibly helpful when dealing with the schema changes. The problem our team has found is doing migrations with subversion.
You run migrations by
paul-pagels-computer:~/RailsProjects/project paulpagel$ rake migrate
Which looks in the schema_info table to find which version of the schema your database is representing, and updates it to the most recent version (the highest number).
The problem comes into play when you have multiple people making migration scripts on their local machine at the same time. If two different people did a migration at the same time and committed them you would end up with two migrations. Which one gets run?
I am not sure how to solve this one yet. I have been loving rails, but this has already has put a dampener on it.

October 18th, 2008 at 06:32 PM Who ever commits first wins! ;-) Just try renaming the migration file from, say, 005_create_customer.rb to 006_create_customer.rb on your machine, mark the conflict resolved, migrate, test and commit. I can't say I've run into this problem yet, but the answer I'm giving is one I read recently.
October 18th, 2008 at 06:32 PM Thanks, we have implemented a lock on migrations(raising your hand and yelling migration) which has worked. The problem only comes into place when you don't notice the duplicate names.
October 18th, 2008 at 06:32 PM Yeah, the migrations/version control interaction has bugged me for some timet, too. Sounds as if the hand raising has got it taken care of for you. Thought I'd point this recent post on [simultaneous migrations](http://blog.caboo.se/articles/2006/12/08/simultaneous-migrations) by courtenay, though, as something to keep in mind. I haven't tried it, yet, but it looks promising.