Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku Schema load: Permission denied for database "postgres" User

I'm trying to deploy my Rails app to Heroku, and I now want to load my schema. I get the following error:

Running `bundle exec rake db:schema:load` attached to terminal... up, run.1533
rake aborted!
PG::ConnectionBad: FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.

Which is weird because postgres is not the database it should connect to. The database URL, which is available to the app via ENV, has the right values, and the long apparently random name d3kwlkwlwjwljetc....

Searching for this message gives me people who are trying to drop or reset the DB, which is not what I'm doing.

  • I have 0 rows
  • I tried pg:reset, even removed and put back the database. No avail.
  • I'm not doing db:drop, just db:schema:load

I'm dumbfounded. Why can't my app connect?

Edit: Apparently, I can't schema:load, but I can migrate all my migrations over. Why is that?

like image 376
Jonathan Allard Avatar asked Jan 08 '15 18:01

Jonathan Allard


People also ask

How do I get Heroku Postgres credentials?

You can create new credentials through both the Heroku CLI and through data.heroku.com. To create the credential through data.heroku.com, select the Credentials tab and click the Create Credential button.


1 Answers

It appears that this is an issue in Rails itself - there is a discussion regarding it at https://github.com/rails/rails/issues/17945 - it seems that there's a commit (https://github.com/rails/rails/blob/master/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb#L77) that is connecting to the posgres database which isn't permitted on Heroku so fails.

In short, for the moment use db:migrate until the issue is resolved.

like image 119
John Beynon Avatar answered Sep 21 '22 11:09

John Beynon