I understand that rails db:migrate
only affects the development database.
When running rspec
with guard-rspec
and spring
, the test environment doesn't automatically apply migrations. Instead, you have to have guard
fail, manually run RAILS_ENV=test rails db:migrate
, and run your rspec guard again. This is expected behavior according to this issue: https://github.com/rails/rails/issues/25804
How could I make it so that either rails db:migrate
does so for both environment at once, or have spring rspec
automatically run pending migrations for the test environment as well?
I'd rather avoid a bash/zsh/shell alias because it has to be set up manually on everyone's machine.
As @stuart said in the comments, the only way is to either RAILS_ENV=test rails db:migrate && RAILS_ENV=development rails db:migrate
or rails db:migrate db:test:prepare
.