1

I am using Michael Hartl's rails tutorials. Whenever I use the following

$ bundle exec rake db:migrate:reset 

Then

$ bundle exec rake db:seed

It waits. It doesn't show anything.

And when I do:

bundle exec rake test

I get

ActiveRecord::PendingMigrationError: Migrations are pending.
To resolve this issue, 
bin/rake db:migrate RAILS_ENV=test

When the above is done-"db:migrate RAILS_ENV=test", tests are clear.

However Michael doesn't mention anything happening about this scenario, Can anybody help and explain?

Karan
  • 100
  • 1
  • 2
  • 8

1 Answers1

1

By default, most rake commands are going to run in the context of the RAILS_ENV passed to the command line. If no RAILS_ENV is passed to the command line, it will run in the development context, which is separate from the test context. There are a few exceptions, like rake db:create, which will create your development and test databases, but migrate will work against the specified environment.

Sean Hill
  • 14,978
  • 2
  • 50
  • 56
  • You mean, I will not have a database in the test environment unless explicitly migrated? – Karan May 03 '15 at 18:13
  • Your database will be there, but the migrations - the things that define all of your tables and columns and such - will not be there. – Sean Hill May 03 '15 at 18:15