To run migrations in the test environment, run this shell command:
test
rake db:migrate RAILS_ENV=test
Starting in Rails 5.0, you can use rails instead of rake:
rails
rake
rails db:migrate RAILS_ENV=test