Destroying a Postgres DB on Heroku

北城余情 提交于 2019-11-26 18:58:01

问题


I want to destroy the database but I'm not sure what the command would be. Does anyone know how to do this?


回答1:


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:

heroku pg:reset DATABASE_URL



回答2:


None of the answers above actually describe how to destroy a Heroku database, which was the original question (and what led me here seeking an answer).

From their docs, either of these will work:

  • heroku addons:destroy heroku-postgresql:tier (where tier is the database tier, like hobby-dev)
  • heroku addons:destroy HEROKU_POSTGRESQL_<COLOR> (if you have more than one database of that tier)

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!




回答3:


To answer Siamii's question above: DATABASE in heroku pg:reset DATABASE is by default postgres




回答4:


Simply follow the steps below. Run

heroku pg:reset DATABASE

to recreate the database with nothing in it, then run

heroku run rake db:migrate

to initialize the database with the correct schema & data.

Look at the new heroku documentation it helps ;)



来源:https://stackoverflow.com/questions/7622633/destroying-a-postgres-db-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!