Joe Essey
Joe Essey

Reputation: 3527

Rake is running latest migration then claiming it hasn't run

I've got a working migration on dev and I'm trying to migrate in test. rake:migrate works up until the latest migration that I added today. I was running db:migrate and it the output was inclusive of the latest migration. I have also confirmed that the table in question exists in my local DB.

When I tried to run rake test:functionals ... I get the following:

You have 1 pending migrations:
  20130506153458 AddProcessingErrorsTable
Run `rake db:migrate` to update your database then try again.

So I ended up running the following command and getting the appropriate output I wanted:

rake db:migrate:redo VERSION=20130506153458 RAILS_ENV=test

==  AddProcessingErrorsTable: reverting =====================
-- drop_table("processing_errors")
   -> 0.0098s
==  AddProcessingErrorsTable: reverted (0.0098s) ============

==  AddProcessingErrorsTable: migrating =====================
-- create_table(:processing_errors)
   -> 0.0185s
==  AddProcessingErrorsTable: migrated (0.0195s) ============

I still get the same error message when I try run the tests now:

You have 1 pending migrations:
  20130506153458 AddProcessingErrorsTable
Run `rake db:migrate` to update your database then try again.

Thanks for any help you can give me.

Upvotes: 0

Views: 1023

Answers (2)

cortex
cortex

Reputation: 5206

Make sure your migrations are up : rake db:migrate:status and try rake db:test:prepare.

Some useful info from Rails Guides.

Upvotes: 0

iltempo
iltempo

Reputation: 16012

Usually you don't have to migrate your test database. It sounds like the development database is not migrated yet. Every time you are running your tests, the development schema is used as a basis for testing db.

Try migrating your development database before running tests:

rake db:migrate

Maybe that's it.

Upvotes: 3

Related Questions