我的 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
当我迁移
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
我尝试过伪造迁移来解决这个问题,但没有成功。这是一个问题,因为任何新的更改都没有注册到我的模型中。
编辑:
显示迁移:
对于我的OM
[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
命令将跳过已创建表的任何迁移。
附注如果你不知道什么是假迁移,check out the explanation .
关于python - Django Makemigrations 和 Migrate 不断重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59851113/