heroku rake 的问题 db:reset
Problems with heroku rake db:reset
我有一个问题,我将我的应用程序推送到 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,作为一个 shared 服务不允许用户访问 drop
或 create
数据库 - 因此当 运行 时出现错误rake db:reset
因此 heroku pg:reset
作为执行数据库重置的命令存在。
我遇到了同样的错误,我已通过
修复了它
heroku pg:reset DATABASE_URL
heroku rake db:migrate
根据你的错误
还有你的database.yml点postgres
用户连接heroku中的数据库
生产模式下不应该是postgres用户
所以
Active Record 4.1+ Escape Valve
If you need need to connect to a different database than the
ENV['DATABASE_URL'] Rails 4.1+ supports a URL key in the database.yml
file that will take precedence.
production:
url: <%= ENV["SOME_OTHER_URL"] %>
我有一个问题,我将我的应用程序推送到 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,作为一个 shared 服务不允许用户访问 drop
或 create
数据库 - 因此当 运行 时出现错误rake db:reset
因此 heroku pg:reset
作为执行数据库重置的命令存在。
我遇到了同样的错误,我已通过
修复了它heroku pg:reset DATABASE_URL
heroku rake db:migrate
根据你的错误
还有你的database.yml点postgres
用户连接heroku中的数据库
生产模式下不应该是postgres用户
所以
Active Record 4.1+ Escape Valve
If you need need to connect to a different database than the ENV['DATABASE_URL'] Rails 4.1+ supports a URL key in the database.yml file that will take precedence.
production:
url: <%= ENV["SOME_OTHER_URL"] %>