1

I have a local version of my app working well, but I'm trying to push the data to my live app. I'm running rails db:migrate RAILS_ENV=production and I get the PG::ConnectionBad: FATAL: role "***" does not exist message.

I'm taking 'username' 'database' and 'password' in my .yml file as the details given under the Database Credentials for my heroku postgres addon

My .yml file:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  adapter: postgresql
  database: postgresql-rectangular-42683
  pool: 5
  timeout: 5000
test:
  adapter: postgresql
  database: postgresql-rectangular-42683
  pool: 5
  timeout: 5000

production:
 adapter: postgresql
 encoding: utf8
 database: ***
 pool: 5
 username: ***
 password: *********
 #host: ***.***.***.*** #-> only for third party db server
Simon Cooper
  • 1,574
  • 4
  • 24
  • 53

1 Answers1

2

Heroku services are dynamic and are subject to being moved amongst their entire fleet of hosts. As such, you should avoid hard coding those database credentials and configuration options. Instead, connect via the DATABASE_URL configuration variable which will be kept up-to-date on your behalf. Documentation for that here.

When you've made those changes and ensured that the migration has been pushed to your heroku remote you can complete the migration by running heroku run rake db:migrate -a <app name>

RangerRanger
  • 2,455
  • 2
  • 16
  • 36