Search code examples
phoenix-frameworkecto

Heroku: reinitialize database for Phoenix


This is mainly for testing purposes, but how can I achieve the same effect as mix ecto.reset on Heroku. The command as such leads to FATAL: permission denied for database "template1" at the drop stage. But I would like to drop all tables and reset all incremental counters, etc.


Solution

  • From what I remember, Heroku don't let you 'drop' databases but do have built in commands that do let you reset the database.

    If you have the CLI toolkit for heroku you should be able to run these commands:

    heroku pg:reset DATABASE_NAME

    Then you can run

    heroku run mix ecto.migrate

    This should reset all of your counters and everything else you were after.

    For more info, have a look at this link here on Heroku's website