gpt4 book ai didi

ruby-on-rails - heroku rake db :reset 的问题

转载 作者:行者123 更新时间:2023-11-29 12:04:26 24 4
gpt4 key购买 nike

我有一个问题,我将我的应用程序推送到 github 并使用 heroku 进行了部署,一切正常,但是当我运行 heroku run --app myapp rake db:reset (填充heroku上的数据库)我发现以下消息充满了错误(我只显示了我认为重要的部分,因为消息太长了)

FATAL:  permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
.
.
.
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `<main>'
Couldn't drop d5q6ajst4p4d97
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
.
.
.
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.0.0/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"utf8", "database"=> [DATABASE], "pool"=>5, "username"=> [USERNAME], "password"=> [PASSWORD], "port"=>5432, "host"=> [HOST]}
-- enable_extension("plpgsql")
-> 0.0370s
-- create_table("heros", {:force=>:cascade})
-> 0.0307s
-- initialize_schema_migrations_table()
-> 0.0579s

注意:我隐藏了用户名、密码等...

在部署的应用程序中一切正常,但我发现在 heroku 中制作 rake db: reset 时看到这么多错误很难看,所以在看到这个之后我搜索了如何解决这个问题并找到了一些宣扬相同解决方案的帖子,所以我按照建议运行命令 heroku pg:reset DATABASE_URL --app myapp,它成功结束,但是当我再次尝试运行时出现相同的错误消息rake db:reset,可能发生了什么?

这是我的database.yml

development:
adapter: postgresql
encoding: utf8
database: project_development
pool: 5
username:
password:

test:
adapter: postgresql
encoding: utf8
database: project_test
pool: 5
username:
password:

production:
adapter: postgresql
encoding: utf8
database: project_production
pool: 5
username:
password:

最佳答案

Heroku,作为一个共享服务,不允许用户删除创建数据库的权限——因此在运行时出现错误 rake 数据库:重置

因此 heroku pg:reset 作为执行数据库重置的命令出现。

参见 https://devcenter.heroku.com/articles/rake

关于ruby-on-rails - heroku rake db :reset 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34702786/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com