python - Django Makemigrations 和 Migrate 不断重复
问题描述
我的 django 应用程序似乎发生了一些事情。有两种模型,一种是我修改的,另一种是新添加的。自从这两个变化以来,我的变化随着迁移数量的增加makemigrations
而migrate
继续保持不变。当我makemigrations
:
Migrations for 'om':
0033_auto_20200122_0001.py:
- Alter field delivery_date on growerpurchaseorderitem
Migrations for 'accounts':
0105_auto_20200122_0001.py:
- Alter field created on pushtoken
- Alter field push_token on pushtoken
当我migrate
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying accounts.0105_auto_20200122_0001... OK
Applying om.0033_auto_20200122_0001... OK
我试图伪造迁移以克服这个问题,但没有运气。这是一个问题,因为任何新的更改都没有注册到我的模型中。
编辑:
显示迁移:
为了我的妈妈
[X] 0030_auto_20200121_2339
[X] 0031_auto_20200121_2343
[X] 0032_auto_20200121_2348
[X] 0033_auto_20200122_0001
我的帐户
[X] 0099_certpdf_expiration_date
[X] 0100_pushtoken
[X] 0101_auto_20200121_2145
[X] 0102_auto_20200121_2339
[X] 0103_auto_20200121_2343
[X] 0104_auto_20200121_2348
[X] 0105_auto_20200122_0001
解决方案
根据我的研究,这很可能是程序出错的地方:
Synchronizing apps without migrations:
尝试创建迁移,然后伪造第一个迁移:
python manage.py makemigrations <app_name>
python manage.py migrate --fake-initial
这些命令将跳过已创建表的任何迁移。
PS 如果您不知道什么是虚假迁移,请查看说明。
推荐阅读
- qt - 如何使用 Qt 应用程序安装和卸载 Win 服务
- java - Spring获取没有注释的entityManger
- jquery - Boostrap 下拉菜单在悬停时关闭
- angularjs - IE11 在 AngularJS 应用程序中用 NTLM 替换 Bearer
- c# - 在 Cmake C# 项目中使用 DLL
- laravel-5 - laravel 5.8 - 创建和更新用户的个人资料
- c - 如何访问内存?
- javascript - 监听窗口属性变化
- angular - 如何将 3 个数据数组合并到一个可迭代数组中?
- ios - “GIDSignIn”类型的值没有成员“presentingViewController”