Unit tests rolling back my migrations

Hey folks–

I’m currently on tag/rel_1-2-3 and have a problem I haven’t encountered
before. I’ve got about 55 total migrations in my database. With this
most recent one, I migrate the test database:

rake RAILS_ENV=test db:migrate

Then I run the unit tests:

rake test:units

Several fail, even though they succeed when run individually. Upon
inspection, I realized that my ‘schema_info’ has gone back to its
previous value. Any idea why this would be happening?

Jake

Ok… So I just ran my migration on RAILS_ENV=development and now “rake
test:units” succeeds and does not rollback my test database.

Is there some linkage here that shouldn’t be there? I tried this
because I noticed a DEPRECATION warning that came up in
'environments/development.rb" and I couldn’t figure out why rake
test:units was running my development environment.

It still, of course, uses the test database.

A little confused,
Jake

Jake J. wrote:

Hey folks–

I’m currently on tag/rel_1-2-3 and have a problem I haven’t encountered
before. I’ve got about 55 total migrations in my database. With this
most recent one, I migrate the test database:

rake RAILS_ENV=test db:migrate

Then I run the unit tests:

rake test:units

Several fail, even though they succeed when run individually. Upon
inspection, I realized that my ‘schema_info’ has gone back to its
previous value. Any idea why this would be happening?

Jake

On 9/5/07, Jake J. [email protected] wrote:

Ok… So I just ran my migration on RAILS_ENV=development and now “rake
test:units” succeeds and does not rollback my test database.

Is there some linkage here that shouldn’t be there? I tried this
because I noticed a DEPRECATION warning that came up in
'environments/development.rb" and I couldn’t figure out why rake
test:units was running my development environment.

It still, of course, uses the test database.

rake test:units calls db:test:prepare, which clones your development
schema to your test schema. That’s what’s wiping out your migrations.

You should not run migrations on the test environment. Run them on the
development environment before running your tests. Also, if you use
autotest (which rocks by the way), you need to run rake
db:test:prepare manually after the migration.

Bob S. wrote:

On 9/5/07, Jake J. [email protected] wrote:

Ok… So I just ran my migration on RAILS_ENV=development and now “rake
test:units” succeeds and does not rollback my test database.

Is there some linkage here that shouldn’t be there? I tried this
because I noticed a DEPRECATION warning that came up in
'environments/development.rb" and I couldn’t figure out why rake
test:units was running my development environment.

It still, of course, uses the test database.

rake test:units calls db:test:prepare, which clones your development
schema to your test schema. That’s what’s wiping out your migrations.

You should not run migrations on the test environment. Run them on the
development environment before running your tests. Also, if you use
autotest (which rocks by the way), you need to run rake
db:test:prepare manually after the migration.

Ah. I see. Thanks for that explanation.

I occasionally run the migration on test first while I’m still testing
the migration to avoid messing up the development database. (since
MySQL doesn’t support transactional migrations – if a migration fails,
I have to fiddle with it by hand to get things back)

Jake

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs