I created a new rails 5 app with postgresql db and modified the database.yml file. I successfully created both development and test databases, but when running migrations only development db is updated and test db remains intact.
Here's the list of commands i used:
rails db:create # Created both development and test
rails db:migrate # Migrated only to development
rails db:migrate RAILS_ENV=test # Does nothing (no error output)
rake db:migrate RAILS_ENV=test # Same result as above
My database.yml file:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: myapp_development
username: myapp_admin
password:
host: localhost
port: 5432
test:
<<: *default
database: myapp_test
username: myapp_admin
password:
host: localhost
port: 5432
I also tried adding ActiveRecord::Migration.maintain_test_schema!
to test_helper.rb
but that didn't work either.
Any suggestions?
I got it to work by removing host: localhost
from database.yml. Now rails db:migrate RAILS_ENV=test
works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With