I'm trying to set my database environment to staging but I get this error:
$ bin/rails db:environment:set RAILS_ENV=staging
rails aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
/Users/bfruitman/workspace/hired/config/environment.rb:5:in `<top (required)>'
/Users/bfruitman/workspace/hired/bin/rails:9:in `<top (required)>'
/Users/bfruitman/workspace/hired/bin/spring:14:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:environment:set => environment
(See full trace by running task with --trace)
I already have an entry in database.yml:
staging:
<<: *heroku
But that's obviously not good enough. Where should I be defining staging?
The best way to change your db environment is with psql:
update ar_internal_metadata set value = 'staging' where key = 'environment';
Replace staging with whatever environment you want to use.
You probably need to add the file: config/environments/staging.rb, it is not included by default, I usually start by copying my production.rb and then making any staging specific changes (if needed).
cp config/environments/production.rb config/environments/staging.rb