Django Heroku Error “Your models have changes that are not yet reflected in a migration”

前端 未结 3 657
北荒
北荒 2020-12-28 18:49

I recently added a model to my app (UserProfile) and when I pushed the changes to Heroku, I think I accidentally ran heroku run python manage.py makemigrations.

3条回答
  •  甜味超标
    2020-12-28 19:07

    You need to first create the migrations locally, add them to your repository, commit the files with the new migrations and then push to heroku.

    The sequence is something like this:

    1. (add/modify some someapp/models.py)
    2. python manage.py makemigrations someapp
    3. python manage.py migrate
    4. git add someapp/migrations/*.py (to add the new migration file)
    5. git commit -m "added migration for app someapp"
    6. git push heroku
    7. heroku run python manage.py migrate
    

提交回复
热议问题