# Does rake db:migrate protect against concurrent use?

**URL:** <https://www.ruby-forum.com/t/does-rake-db-migrate-protect-against-concurrent-use/165745>\
**Category:** Rails\
**Created:** [April 17, 2009, 12:09am UTC](https://www.ruby-forum.com/t/does-rake-db-migrate-protect-against-concurrent-use/165745 "2009-04-17T00:09:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [April 17, 2009, 12:09am UTC](https://www.ruby-forum.com/t/does-rake-db-migrate-protect-against-concurrent-use/165745/1 "2009-04-17T00:09:42Z")

</div>

If two people go to the same rails application (same directory) and  
both run “rake db:migrate” to update the database with a set of  
migrations (the same ones) at the same time, is it likely that bad  
things will happen to the data, or will db:migrate do something to  
prevent the same migration from being run by more than one  
(simultaneous) process?

Thanks,  
–Paul

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [April 17, 2009, 12:51am UTC](https://www.ruby-forum.com/t/does-rake-db-migrate-protect-against-concurrent-use/165745/2 "2009-04-17T00:51:15Z")

</div>

> If two people go to the same rails application (same directory) and  
> both run “rake db:migrate” to update the database with a set of  
> migrations (the same ones) at the same time, is it likely that bad  
> things will happen to the data, or will db:migrate do something to  
> prevent the same migration from being run by more than one  
> (simultaneous) process?

rake db:migrate is only tuned for one development workstation.

Are you implying your developers don’t have individual databases?

In my experience running various rake commands accidentally at the same  
time, one batch will “win”, and the other will cough up a zillion errors  
and  
expire gracelessly…

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [April 18, 2009, 11:52pm UTC](https://www.ruby-forum.com/t/does-rake-db-migrate-protect-against-concurrent-use/165745/3 "2009-04-18T23:52:39Z")

</div>

Depending on your DB, it may support transactional migrations (as of  
Rails 2.2). That should ensure that only one set of changes go  
through. Haven’t ever tried it, but it should probably work.

–Matt J.
