Forum: Ruby on Rails Migration collisions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0ab34d2b45720a2b4060b6d7abeef339?d=identicon&s=25 Adam Thorsen (awt)
on 2006-06-04 17:22
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
807e34b31d5463a9ac05d41458a9e537?d=identicon&s=25 Al Evans (al-evans)
on 2006-06-04 22:57
Adam Thorsen 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:-)
:-)

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
Be09addcbb47f2a684fa5c48bac94149?d=identicon&s=25 David Johnson (Guest)
on 2006-06-05 02:25
(Received via mailing list)
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.
0ab34d2b45720a2b4060b6d7abeef339?d=identicon&s=25 Adam Thorsen (awt)
on 2006-06-05 03:02
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 Thorsen 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:-)
> :-)
>
> 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
This topic is locked and can not be replied to.