# Testing and migrations

**URL:** <https://www.ruby-forum.com/t/testing-and-migrations/190749>\
**Category:** Rails\
**Created:** [June 26, 2010, 6:32pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749 "2010-06-26T18:32:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 26, 2010, 6:32pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/1 "2010-06-26T18:32:34Z")

</div>

does rails always need to update the development database before  
running the  
tests? It seems to insisit on running db:migrate before. Why can’t it  
just update  
the test database? This can be annoying if I’m in a production  
environment and I  
don’t want a migration to happen until I know the tests pass. How are  
people  
dealing with this?

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 27, 2010, 3:46pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/2 "2010-06-27T15:46:10Z")

</div>

Rake db:test:clone?

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 27, 2010, 3:47pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/3 "2010-06-27T15:47:45Z")

</div>

anywho wrote:

> does rails always need to update the development database before  
> running the  
> tests? It seems to insisit on running db:migrate before. Why can’t it  
> just update  
> the test database? This can be annoying if I’m in a production  
> environment and I  
> don’t want a migration to happen until I know the tests pass.

Your production DB is not the dev DB, so you needn’t migrate it before  
tests pass You can also just migrate the test DB itself

How are

> people  
> dealing with this?

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 27, 2010, 4:02pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/4 "2010-06-27T16:02:35Z")

</div>

On Sun, Jun 27, 2010 at 6:47 AM, Marnen Laibow-Koser  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> anywho wrote:
> 
> > does rails always need to update the development database before  
> > running the  
> > tests? It seems to insisit on running db:migrate before.
> 
> Your production DB is not the dev DB, so you needn’t migrate it before  
> tests pass You can also just migrate the test DB itself

Which ignores the original question, rephrased:

1. generate a migration
2. migrate your test db
3. run `rake test:units`

You’ll get a prompt to run migrations, which only goes away if you  
migrate your _development_ db.

I also find that behavior strange.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 27, 2010, 9:46pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/5 "2010-06-27T21:46:14Z")

</div>

I also don’t use Test::Unit. I use Rspec, and I assumed, correctly it  
would seem, that the behavior was the same.

Rake db:test:clone just clones from the development, no?

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 27, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/6 "2010-06-27T16:27:34Z")

</div>

Hassan S. wrote:

> On Sun, Jun 27, 2010 at 6:47 AM, Marnen Laibow-Koser  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > anywho wrote:
> > 
> > > does rails always need to update the development database before  
> > > running the  
> > > tests? It seems to insisit on running db:migrate before.
> > 
> > Your production DB is not the dev DB, so you needn’t migrate it before  
> > tests pass ï¿½ You can also just migrate the test DB itself
> 
> Which ignores the original question, rephrased:
> 
> 1. generate a migration
> 2. migrate your test db
> 3. run `rake test:units`
> 
> You’ll get a prompt to run migrations, which only goes away if you  
> migrate your _development_ db.
> 
> I also find that behavior strange.

I’ve never done it in that order, so didn’t realize that part. I also  
don’t use Test::Unit; not sure if that’s significant. Thanks for the  
clarification.

> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

---

<div class="post-metadata">

**Author:** ![anywho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@anywho](https://www.ruby-forum.com/u/anywho)\
**Post date:** [June 28, 2010, 5:44pm UTC](https://www.ruby-forum.com/t/testing-and-migrations/190749/7 "2010-06-28T17:44:43Z")

</div>

yes it does
