Last active
October 23, 2020 08:42
-
-
Save kylefox/7044491259b6b2586ca1 to your computer and use it in GitHub Desktop.
Run Django database migrations after deploy to Heroku. This file must live at `bin/post_compile` within your root project directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/usr/bin/env bash | |
# File path should be ./bin/post_compile | |
# (.sh extension added in Gist just to enable shell syntax highlighting. | |
# https://discussion.heroku.com/t/django-automaticlly-run-syncdb-and-migrations-after-heroku-deploy-with-a-buildpack-or-otherwise/466/7 | |
echo "=> Performing database migrations..." | |
python manage.py migrate |
i think you can just use the release
command in your Procfile
for exemple to migrate :
release: python manage.py migrate
web: gunicorn django_proj.wsgi --log-file -
or runs a script :
release: ./ post_compile.sh
web: gunicorn django_proj.wsgi --log-file -
the command release
runs after :
- A successful app build
- A change to the value of a config var (unless the config var is associated with an add-on)
- A pipeline promotion
- A rollback
- A release via the platform API
- Provisioning a new add-on
Just do:
release: python manage.py migrate --no-input
web: gunicorn project_name.wsgi
and you will be fine.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This solution may be outdated with the
release
option of theProcfile
.See StackOverflow answer or Heroku doc.