gpt4 book ai didi

python - django.db.migrations.exceptions.InconsistentMigrationHistory : Migration . ..在其依赖项之前应用

转载 作者:太空宇宙 更新时间:2023-11-03 14:02:17 25 4
gpt4 key购买 nike

我得到这个异常:

myproject@aptguettler:~$ manage.py migrate
Traceback (most recent call last):
File "/home/myproject/src/djangotools/djangotools/bin/manage.py", line 32, in <module>
main()
File "/home/myproject/src/djangotools/djangotools/bin/manage.py", line 29, in main
execute_from_command_line()
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/myproject/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 86, in handle
executor.loader.check_consistent_history(connection)
File "/home/myproject/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 292, in check_consistent_history
connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration myapp.0029_bar is applied before its dependency myapp.0005_foo_squashed_0028_dynamic_year on database 'default'.

我的迁移:

                   name                    
-------------------------------------------
0001_initial
0002_...
0003_...
0004_...
0005_foo
0006_...
0007_...
...
0028_dynamic_year
0029_bar
0030_...

可能是什么原因?

最佳答案

在队友的帮助下我找到了原因。

他这样做了:

  1. 压制迁移
  2. 生产部署和 makemigrations
  3. 删除了迁移目录中压缩的 python 文件

我更新了我的(旧)开发系统中的 git 存储库。然后进行迁移引发上述异常。

Django 无法解决这个问题,因为有些迁移已应用,有些则未应用,而且旧的压缩迁移文件不再可用。

我采用了最简单的解决方案:我删除了开发数据库并从头开始创建它。

关于python - django.db.migrations.exceptions.InconsistentMigrationHistory : Migration . ..在其依赖项之前应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49154158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com