# Migration collisions

**URL:** <https://www.ruby-forum.com/t/migration-collisions/62425>\
**Category:** Rails\
**Created:** [June 4, 2006, 5:22pm UTC](https://www.ruby-forum.com/t/migration-collisions/62425 "2006-06-04T17:22:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [June 4, 2006, 5:22pm UTC](https://www.ruby-forum.com/t/migration-collisions/62425/1 "2006-06-04T17:22:40Z")

</div>

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…

> **[Guruza.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=guruza.com)**
>
> Great domain names provide SEO, branding, and a memorable experience for your users. Get a premium domain today.

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [June 4, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/migration-collisions/62425/2 "2006-06-04T22:57:06Z")

</div>

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:-)  
🙂

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

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [June 5, 2006, 2:25am UTC](https://www.ruby-forum.com/t/migration-collisions/62425/3 "2006-06-05T02:25:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [June 5, 2006, 3:02am UTC](https://www.ruby-forum.com/t/migration-collisions/62425/4 "2006-06-05T03:02:42Z")

</div>

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:-)  
> 🙂
> 
> 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
