Ilya Bibik
Ilya Bibik

Reputation: 4134

What to do to run makemigrations/migrate on heroku when deploying changed models from github?

I have deployed app from github repository to the heroku account of my customer as collaborator but this time I had to add some new models.

However I realized that when I deploy my changes from github heroku does not run makemigrations and migrate.

I I read some answers on stackoverflow and understood this is how it is supposed to be.

However my question is what should I do ? What is the best practise to deploy change models to heroku app. (I assume it is not deleting and recreating my app again since customer already has data there.)

(I am able to run makemigrations and migrate from the bash manually but when I have 30+ deployments it's a pain)

Upvotes: 0

Views: 1132

Answers (1)

jmccartie
jmccartie

Reputation: 4976

Check out the new feature on Heroku called "Release Phase": https://devcenter.heroku.com/articles/release-phase It will allow you to run migrations during the deployment. Just add whatever command you want to your Procfile, like this:

web: your_web_command
release: python manage.py migrate

The release command will run after your app is done building, and before it's launched.

Upvotes: 6

Related Questions