Josh Glover
Josh Glover

Reputation: 26180

Running migrations against the Rails test environment

I know that I can run specific migrations:

rake db:migrate:up VERSION=20080906120000

But can I run a specific migration against my test database? Will the following work?

RAILS_ENV=test rake db:migrate:up VERSION=20080906120000

In theory, running the migrations in default mode (which should affect the development database) and then running rake db:test:prepare should get the job done, but I found something strange with my test database after doing that, and I need to run a specific migration on the test database to aid my troubleshooting.

I'd just try out the above rake command, except I'm in the middle of a long data seeding run on my development database, and I can't risk the migration interfering with that, so I figured I'd see if anyone knows the answer before I can determine it myself. :)

Upvotes: 30

Views: 21177

Answers (1)

Adrian Serafin
Adrian Serafin

Reputation: 7725

In different order:

rake db:migrate:up VERSION=20080906120000 RAILS_ENV=test

Upvotes: 46

Related Questions