Topic: Rake db:migrates doesn't migrate test database

I create a new migration to add/change a field I forgot. Then I run 'rake db:migrate'. My development database get the field added just fine, but the test database does not. Therefore, when I run the 'rake test' I get mucho errors.

I though 'rake db:migrate' also updated the test database? Or 'rake test' was suppoed to reload the complete schema.rb each time it loads the fixutres? It doesn't seem to be doing either.

Why?

PS- I know a solution... 'rake db:test:prepare', but I thought rake was supposed to do this automatically for me.

Re: Rake db:migrates doesn't migrate test database

When you run a migration it will operate in your current environment, which is normally the development environment. To migrate in the test environment, do the following:

rake environment RAILS_ENV=test db:migrate

Re: Rake db:migrates doesn't migrate test database

Ok, that makes sense, sort of.

Then why doesn't 'rake test' account for migrations that may have been run by applying the schema.rb before the test execution? Makes sense to me #hmm#

Re: Rake db:migrates doesn't migrate test database

You don

Re: Rake db:migrates doesn't migrate test database

Found this from a google search. The answer I found from working in Rails 3 is that rake db:migrate just does the current env. Running just rake will migrate your test db if running tests is the default rake action. After that, autotest will work since it won't migrate either.