Python “Django Heroku错误”;您的模型具有尚未反映在迁移中的更改”;
我最近在我的应用程序(UserProfile)中添加了一个模型,当我将更改推送到Heroku时,我想我无意中运行了Python “Django Heroku错误”;您的模型具有尚未反映在迁移中的更改”;,python,django,heroku,django-1.7,django-migrations,Python,Django,Heroku,Django 1.7,Django Migrations,我最近在我的应用程序(UserProfile)中添加了一个模型,当我将更改推送到Heroku时,我想我无意中运行了Heroku run python manage.py makemigrations。现在,当我尝试运行heroku run python manage.py migrate时,我得到以下错误 (leaguemaster) benjamins-mbp-2:leaguemaster Ben$ heroku run python manage.py migrate Running `py
Heroku run python manage.py makemigrations
。现在,当我尝试运行heroku run python manage.py migrate
时,我得到以下错误
(leaguemaster) benjamins-mbp-2:leaguemaster Ben$ heroku run python manage.py migrate
Running `python manage.py migrate` attached to terminal... up, run.1357
Operations to perform:
Synchronize unmigrated apps: allauth
Apply all migrations: auth, admin, socialaccount, sites, accounts, account, contenttypes, sessions, leagueapp
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
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.
我该如何解决这个问题?请帮忙 您需要首先在本地创建迁移,将它们添加到存储库中,用新迁移提交文件,然后推送到heroku 顺序是这样的:
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
这听起来像是在对模型进行更改之后,但在创建初始迁移文件之前运行了
makemigrations
。尝试将应用还原到添加新模型之前的状态,然后再次运行makemigrations
以创建初始迁移。然后将更新添加回并再次运行makemigrations
。这将创建从初始数据结构到新的更新数据结构的第二次迁移。然后尝试部署
$python manage.py makemigrations&&python manage.py migrate
$git add--all
$git commit-m“修复了迁移错误”
$git推送heroku主机
$heroku运行python manage.py makemigrations
$heroku运行python manage.py迁移
您还必须意识到,您并没有忽略迁移路径
.gitingnore
首先-非常感谢您尝试帮助我。现在,我当地的环境是最新的,工作如我所料。当我运行git status
时,它会显示我的文件是最新的,当我运行git push heroku master
时,它会显示所有内容都是最新的。然而,当我运行heroku run python manage.py migrate时,正如我所描述的,我得到了一个错误“您的模型有尚未反映在迁移中的更改”。还有什么其他的想法或建议需要我解决吗?看来你的存储库是不同步的;你有任何未跟踪的文件吗?如果你指的是我的.gitignore文件,它是此文件的副本,没有任何额外内容。我在heroku中删除了我的应用程序,但当我将其添加回时,我仍然收到相同的错误!有没有可能请你帮我解决这个问题?你能从中得到什么:git ls文件--排除标准-其他
?谢谢allauth.socialaccount
向我提供了错误信息。最后我把它扔了,然后一切都好了。其他人在这里报告了这个错误,希望他们能想出一个补丁。我想我之所以来到这里,是因为我改变了安装的应用程序的顺序。我看不出还有其他原因,是的,你永远不需要在heroku服务器上进行迁移。您应该始终在本地进行迁移,然后将迁移推送到服务器。您应该只需要在服务器上进行迁移。