Migration collisions


#1

Does someone have a good way to avoid numbering collisions when
generating migrations in multiple source repositories? For example, I’m
working on my copy of the site, and my co-worker is working on his copy
of the site. We both need to make a migration, and they both end up
having the same number, say 007_add_user_table.rb

Is there some technique to avoid this?

I’m offering a $20.00 reward for the solution…

http://guruza.com/question/74/reward-20.00


#2

Adam T. wrote:

Does someone have a good way to avoid numbering collisions when
generating migrations in multiple source repositories? For example, I’m
working on my copy of the site, and my co-worker is working on his copy
of the site. We both need to make a migration, and they both end up
having the same number, say 007_add_user_table.rb

Is there some technique to avoid this?

(I’m sort of assuming you’re using Subversion – if you’re not, you
should. I’m also assuming you don’t really have “multiple source
repositories” – if you each have your own repository, all bets are
off:-)
:slight_smile:

I can’t think of one, except that you should make it a rule to update
your source tree immediately before adding a migration and commit your
changes immediately after. If both migrations have the same name, you
should get a conflict. If happen to end up with two different migrations
with different names, but the same number, you could just do ‘svn rename
007_add_user_table.rb 008_add_user_table.rb’

–Al Evans


#3

You might want to look at SVK if you have multiple source repositories.

SVK is a wrapper that uses SVN as the core for a distributed source
repository system.


#4

Al,

Thanks. I think that’s a very good solution. I’m not using SVN, I’m
using Mercurial, btw. I just like it because it’s distributed and I
don’t have to keep a server running to use it.

-Adam

Al Evans wrote:

Adam T. wrote:

Does someone have a good way to avoid numbering collisions when
generating migrations in multiple source repositories? For example, I’m
working on my copy of the site, and my co-worker is working on his copy
of the site. We both need to make a migration, and they both end up
having the same number, say 007_add_user_table.rb

Is there some technique to avoid this?

(I’m sort of assuming you’re using Subversion – if you’re not, you
should. I’m also assuming you don’t really have “multiple source
repositories” – if you each have your own repository, all bets are
off:-)
:slight_smile:

I can’t think of one, except that you should make it a rule to update
your source tree immediately before adding a migration and commit your
changes immediately after. If both migrations have the same name, you
should get a conflict. If happen to end up with two different migrations
with different names, but the same number, you could just do ‘svn rename
007_add_user_table.rb 008_add_user_table.rb’

–Al Evans