如何rake db:drop和rake db:create on Heroku?

编程入门 行业动态 更新时间:2024-10-09 09:11:38
本文介绍了如何rake db:drop和rake db:create on Heroku?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复: 如何清空heroku中的数据库

Heroku上的Postgres数据库。它是一个免费的测试版。在本地,当测试时,我经常运行rake db:drop&& rake db:create&& rake db:migrate作为重置数据库的方式。

但是,当我尝试在Heroku上运行时,会出现错误:

无法删除mydatabaseid:#< PG :: Error:FATAL:数据库postgres被拒绝详细信息:用户没有CONNECT权限。

嗯,好吧,我该怎么完全重置我的数据库,迁移和一切? p>

解决方案

pg:reset 命令将为您重新创建数据库。用法示例:

$ heroku config | grep POSTGRESQL HEROKU_POSTGRESQL_RED_URL:postgres:// somedatabaseurl $ heroku pg:reset HEROKU_POSTGRESQL_RED_URL !警告:破坏性操作!这个命令将影响应用程序:myappname !要继续,请键入myappname或重新运行此命令与--confirm > myappname 重设HEROKU_POSTGRESQL_RED_URL(DATABASE_URL)... done

db:reset 命令将尝试删除数据库,这不是Heroku的权限允许的。

Possible Duplicate: How to empty DB in heroku

I have a Postgres database on Heroku. It is one of the free beta ones. Locally, when testing, I often run rake db:drop && rake db:create && rake db:migrate as a way to reset the database.

However, when I try to run this on Heroku, I get the error:

Couldn't drop mydatabaseid : #<PG::Error: FATAL: permission denied for database "postgres" DETAIL: User does not have CONNECT privilege.

Uh, ok, so how am I supposed to completely reset my database, migrations and everything?

解决方案

The pg:reset command will recreate the database for you. Example usage:

$ heroku config | grep POSTGRESQL HEROKU_POSTGRESQL_RED_URL: postgres://somedatabaseurl $ heroku pg:reset HEROKU_POSTGRESQL_RED_URL ! WARNING: Destructive Action ! This command will affect the app: myappname ! To proceed, type "myappname" or re-run this command with --confirm > myappname Resetting HEROKU_POSTGRESQL_RED_URL (DATABASE_URL)... done

The db:reset command would try to drop the database, which is not something that Heroku's permissions allow.

更多推荐

如何rake db:drop和rake db:create on Heroku?

本文发布于:2023-10-18 15:30:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:db   rake   drop   Heroku   create

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!