Commands to reset a Heroku database

If you want to reset your Heroku database, just run the following commands:

  1. heroku restart
  2. heroku pg:reset DATABASE (don’t change DATABASE)
  3. heroku run rails db:migrate
  4. heroku run rails db:seed (if you use seed.rb)

You can also do this in a one-liner. Just replace CHANGEME with the name of your app; for instance, whispering-woods-123456:

heroku restart && heroku pg:reset DATABASE --confirm CHANGEME && heroku run rake db:migrate

I found this information from a gist on GitHub by Zulhilmi Zainudin and Jean-Michel Gigault and saved it here for posterity and easy access.

I'm Mark Thomas Miller, an engineer, designer, and maker of things.