Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rake db:drop and rake db:create on Heroku? [duplicate]

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?

like image 258
Geoff Avatar asked Jun 12 '12 03:06

Geoff


1 Answers

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.

like image 129
Neil Middleton Avatar answered Oct 02 '22 11:10

Neil Middleton