Reset Postgres DB on Heroku

In a Rails application you can you this tasks on localhost to reset the database.

rake db:drop
rake db:create
rake db:migrate

And that will delete the db schema, create a new one and run all migrations to create the tables. This is awesome!
But if try to run this on heroku:

heroku run rake db:drop

Than you will get an exception, because you don’t have permission to delete dbs on Heroku. If you want to reset your database on Heroku you have to use this command:

heroku pg:reset DATABASE_URL

this is equal to “rake db:drop” and “rake db:create”. After that you still have to run:

heroku run rake db:migrate

That worked pretty good for me.
Just wanted to share my experience.

Published by Robert Reiz

CEO @ VersionEye. Passionated software developer since 1998.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: