Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How heroku run python manage.py migrate?

I deployed a simple Django app in Heroku

Steps:

- git push heroku master

- heroku run python manage.py makemigrations ( or + app_name)

it seem to affect:

  0002_main.py:
- Create model Comment
- Remove field status from match
- Remove field quantity from slot
- Add field avatar to account
- Add field slots to match
- Alter field verification_code on account
- Alter field verification_code on slot
- Add field match_object to comment
- Add field user to comment
- Alter index_together for comment (1 constraint(s))

then I run

- heroku run python manage.py migrate

but i received:

  Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
like image 697
khue bui Avatar asked Nov 24 '16 15:11

khue bui


People also ask

When should I run Python manage PY migrate?

migrate executes those SQL commands in the database file. So after executing migrate all the tables of your installed apps are created in your database file. You can confirm this by installing SQLite browser and opening db.


Video Answer


2 Answers

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.

like image 196
Zaman Afzal Avatar answered Oct 21 '22 22:10

Zaman Afzal


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.

like image 29
Sayse Avatar answered Oct 21 '22 21:10

Sayse