33

当我尝试运行时:

heroku run rake db:drop db:create db:migrate

我得到错误:

Running rake db:drop attached to terminal... up, run.5
Couldn't drop adsfsadfas : #<ActiveRecord::StatementInvalid: PGError: ERROR:  must be owner of database adsfsadfas
: DROP DATABASE IF EXISTS "adsfsadfas">

我在 Heroku Cedar 堆栈上。我可以在 Heroku 上删除数据库吗?

谢谢!

约翰

4

2 回答 2

51

不支持 rake db:reset 任务。Heroku 应用无权删除和创建数据库。请改用该heroku pg:reset命令。

于 2011-11-17T05:13:04.967 回答
13

heroku 上不允许使用直接破坏性命令(dropcreate )。但是,如果您可以丢失所有数据,您可以使用pg:reset.

heroku pg:reset DATABASE_URL

其他所有更改都应使用db:migrate. 这保证了数据库状态的一致性。


如果您的迁移不再通过完整堆栈运行,您可以使用db:schema:load. 这直接从schema.rb加载模式。create_table但请注意,如果使用参数force: true或,这也可能具有破坏性force: :cascade

heroku run rake db:schema:load
于 2015-06-05T08:59:10.370 回答