djangoherokuheroku-postgresheroku-cli

Migrate Issue on Heroku


I have hosted the django application in Heroku environmnet. Whenever I try to initiate migrate command its shows error:

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. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

I also checked with new database on same application eventhough same issue. Finally I have tried makemigrations its done well, but after makemigrations also having same issue. The same I have tried with another application in same heroku makemigrations and migrate working well.

Please suggest why I can't migrate on previous application in heroku.

enter image description here


Solution

  • Here two way to solve this problem:

    1. Don't run makemigrations command in Heroku bash. Run makemigrations locally to create migration files and Run migrate locally then commit the result and push, and then run migrate command on Heroku.

    OR

    1. If your existing database have not contain any useful data then destroy it :-

    Go to heroku >> your app >> Resources >> select Heroku Postgres >> Settings >> select Destroy Database..

    After this follow again first way.