Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save masroorhussainv/144611cc540b074ab54bd48e17585250 to your computer and use it in GitHub Desktop.
Save masroorhussainv/144611cc540b074ab54bd48e17585250 to your computer and use it in GitHub Desktop.
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart -a app_name
  • Step 2: heroku pg:reset DATABASE -a app_name (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate -a app_name
  • Step 4: heroku run rake db:seed -a app_name (if you have seed)

One liner

heroku restart -a app_name; heroku pg:reset DATABASE -a app_name --confirm APP-NAME; heroku run rake db:migrate -a app_name

Note 1

Heroku doesn't allow users from using rake db:reset, rake db:drop and rake db:create command. They only allow heroku pg:reset and rake db:migrate commands.

More info: https://devcenter.heroku.com/articles/rake

Note 2

If you have more than 1 remote, append --remote [your_remote_name] like this:

heroku run rake db:migrate --remote dev (dev is example remote here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment