Forum: Ruby on Rails Testing Migrations

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.
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-03-09 17:43
(Received via mailing list)
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
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2006-03-09 18:10
(Received via mailing list)
rake migrate RAILS_ENV=test

Duane Johnson
(canadaduane)
http://blog.inquirylabs.com/
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-03-09 18:20
(Received via mailing list)
Somehow that makes perfect sense!  Thanks!

_Kevin
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-03-09 18:29
(Received via mailing list)
On 9 Mar 2006 16:42:40 -0000, Kevin Olbrich
<devlists-rubyonrails@devlists.com> 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.
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-03-09 19:15
(Received via mailing list)
On Mar 9, 2006, at 9:27 AM, Joe Van Dyk 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 Mornini
This topic is locked and can not be replied to.