Testing Migrations

Is there some standard way to test migrations?

It seems to me that an additional safeguard for migrations would be to
test and see if applying the migrations to the test database allows one
to reconstruct the structure of the development database.

If you can’t, then there is an error in your migrations, most likely
because someone hand-modified the database without generating a
migration for it.

The biggest problem with writing unit tests for this is that (AFAIK)
there is no simple way to apply migrations to the test database instead
of the development one.

Is there a simple switch or something in rake that will make it use the
test database?

_Kevin

rake migrate RAILS_ENV=test

Duane J.
(canadaduane)
http://blog.inquirylabs.com/

Somehow that makes perfect sense! Thanks!

_Kevin

On 9 Mar 2006 16:42:40 -0000, Kevin O.
[email protected] wrote:

The biggest problem with writing unit tests for this is that (AFAIK)
there is no simple way to apply migrations to the test database instead
of the development one.

Is there a simple switch or something in rake that will make it use the
test database?

I have a script that:

  • removes the development and test database
  • creates the development and test database
  • performs the migrations on the development database
  • loads my test fixtures into the development database
  • and runs all unit and functional tests

So, if there’s a mistake in the migrations, it shows up when the
script runs (i.e. migration fails or the tests fail). And it’s easy
to fix the problem and do it again.

On Mar 9, 2006, at 9:27 AM, Joe Van D. wrote:

  • removes the development and test database
  • creates the development and test database
  • performs the migrations on the development database
  • loads my test fixtures into the development database
  • and runs all unit and functional tests

+1


– Tom M.