django heroku makemigrations ignoring changes in m

2019-08-03 19:41发布

问题:

I deleted two models from models.py, and when I run makemigrations and migrate locally, everything is fine. When I run makemigrations on Heroku, I get the following message, where Building and BuildingInstance are the models I deleted:

Migrations for 'hello':
0002_building_buildinginstance.py:
- Create model Building
- Create model BuildingInstance

When I run migrate, I get:

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.

I followed the steps here and also tried squashing the migrations locally and on Heroku as suggested here. How can I fix this problem?

回答1:

As I have written many times here, you must not run makemigrations on Heroku. Run it locally, commit the result, and then​ run migrate on Heroku.