Django Heroku错误“您的模型具有尚未反映在迁移中的更改” [英] Django Heroku Error "Your models have changes that are not yet reflected in a migration"

查看:1039
本文介绍了Django Heroku错误“您的模型具有尚未反映在迁移中的更改”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在我的应用程序(UserProfile)中添加了一个模型,当我将更改推送到Heroku时,我想我不小心运行了 heroku run python manage.py makemigrations 。现在当我尝试运行 heroku运行python manage.py migrate 我得到以下错误

 (leaguemaster)benjamins-mbp-2:leaguemaster本$ heroku运行python manage.py migrate 
运行`python manage.py migrate`附加到终端... up,run.1357
执行操作:
同步未迁移的应用程序:allauth
应用所有迁移:auth,admin,socialaccount,网站,帐户,帐户,内容类型,会话,leagueapp
不迁移同步应用程序:
创建表...
安装自定义SQL ...
安装索引...
运行迁移:
无需迁移。
您的模型具有尚未反映在迁移中的更改,因此不会应用。
运行'manage.py makemigrations'进行新的迁移,然后重新运行'manage.py migrate'以应用它们。

如何解决这个问题?请帮助!

解决方案

您需要先在本地创建迁移,将它们添加到您的存储库,使用新的迁移提交文件然后推到英雄。



顺序是这样的:

  1。 (添加/修改someapp / models.py)
2. python manage.py makemigrations someapp
3. python manage.py migrate
4. git add someapp / migrations / *。py(添加新的迁移文件)
5. git commit -m为应用程序添加了一些迁移
6. git push heroku
7. heroku运行python manage.py migrate


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. Now when I try to run heroku run python manage.py migrate I get the error below

(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.

How do I fix this? Please help!

解决方案

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

这篇关于Django Heroku错误“您的模型具有尚未反映在迁移中的更改”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆