简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM