postgresql 在 Heroku 上销毁 Postgres 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7622633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Destroying a Postgres DB on Heroku
提问by captDaylight
I want to destroy the database but I'm not sure what the command would be. Does anyone know how to do this?
我想销毁数据库,但我不确定命令是什么。有谁知道如何做到这一点?
回答by CraigKerstiens
You shouldn't use a postgres command to fully delete your database, as you will not have permissions to create a new one. Instead you should use the heroku command to clear out your database:
您不应使用 postgres 命令完全删除您的数据库,因为您将无权创建新数据库。相反,您应该使用 heroku 命令来清除您的数据库:
heroku pg:reset DATABASE_URL
回答by JacobEvelyn
None of the answers above actually describe how to destroya Heroku database, which was the original question (and what led me here seeking an answer).
上面的答案都没有真正描述如何销毁Heroku 数据库,这是最初的问题(以及是什么让我在这里寻求答案)。
From their docs, either of these will work:
从他们的 docs,这些都可以工作:
heroku addons:destroy heroku-postgresql:tier
(wheretier
is the database tier, likehobby-dev
)heroku addons:destroy HEROKU_POSTGRESQL_<COLOR>
(if you have more than one database of that tier)
heroku addons:destroy heroku-postgresql:tier
(tier
数据库层在哪里,比如hobby-dev
)heroku addons:destroy HEROKU_POSTGRESQL_<COLOR>
(如果您有多个该层的数据库)
Note that because this is a destructive action it will prompt you to confirm the action. If you want to use this in a script you can skip the prompt with something like this:
请注意,因为这是一个破坏性操作,它会提示您确认该操作。如果你想在脚本中使用它,你可以跳过这样的提示:
heroku addons:destroy HEROKU_POSTGRESQL_<COLOR> --confirm <appname>
Hope that's helpful!
希望这有帮助!
回答by Jordan Townsend
To answer Siamii's question above: DATABASE
in heroku pg:reset DATABASE
is by default postgres
回答 Siamii 的上述问题:默认为DATABASE
inheroku pg:reset DATABASE
postgres
回答by Ronaldoh1
Simply follow the steps below. Run
只需按照以下步骤操作即可。跑
heroku pg:reset DATABASE
heroku pg:reset DATABASE
to recreate the database with nothing in it, then run
重新创建没有任何内容的数据库,然后运行
heroku run rake db:migrate
heroku run rake db:migrate
to initialize the database with the correct schema & data.
使用正确的架构和数据初始化数据库。
Look at the new heroku documentation it helps ;)
看看它有帮助的新 heroku 文档;)