How heroku run python manage.py migrate?
Make sure you have committed migrations file. then run
heroku run python manage.py migrate
You can specify the app name in the following way:
heroku run python manage.py migrate -a <app-name>
Please see this documentation.
Either
heroku run python manage.py migrate
or
heroku run python3 manage.py migrate
If needed to specify app name:
heroku run python3 manage.py migrate -a <app-name>
Your migration files should be committed to your source control, and never run makemigrations
on heroku.
With committed migration files, this problem becomes non existant.
The Heroku filesystem is read-only as per the documentation.
This means that when you disconnect from the dyno the files created by the makemigrations
command will be destroyed.
To solve your issue you can:
- Commit your migration files to Github(or your source control system) and then run the
migrate
command on the Heroku shell - recommended - Create the migration files and then run the migration on the heroku bash shell. - NOT RECOMMENDED on production