django.db.migrations.exceptions.InconsistentMigrationHistory error as part of 6.0.1 to 6.1 upgrade

戏子无情 提交于 2019-12-11 19:06:42

问题


Environment: running Kiwi in docker containers from Docker repository on Windows Server 2016. I have not made changes to my clone of the Kiwi repo or the docker images.

Repro:
1. Follow upgrade steps on blog to upgrade/migrate from Kiwi 6.0 to 6.0.1
2. Repeat steps to upgrade/migrate from Kiwi 6.0.1 to 6.1

Expect:
No errors

Result:
Exception during migration, I clicked around my Kiwi instance after running the migrate command and didn't see anything obviously wrong with the data or associations between cases, plans and runs. But early days...

Full call stack:

C:\Kiwi>docker exec -it kiwi_web /Kiwi/manage.py migrate
Traceback (most recent call last):
  File "/Kiwi/manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 85, in handle
    executor.loader.check_consistent_history(connection)
  File "/venv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 297, in check_consistent_history
    connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration management.0013_remove_env is applied before its dependency testruns.0019_remove_testruntag_user on database 'default'.

回答1:


Argh, this shouldn't happen.

Repro: 1. Follow upgrade steps on blog to upgrade/migrate from Kiwi 6.0 to 6.0.1

Can you describe the steps exactly ? If you did a git pull then your docker-compose.yml points to kiwitcms/kiwi:latest and you have to manually modify that for the intermediate upgrade step.

  1. Repeat steps to upgrade/migrate from Kiwi 6.0.1 to 6.1

When did you get the traceback, before step 2 or after step 2 ?

Note: This is similar to https://github.com/kiwitcms/Kiwi/issues/561 and there isn't much we can do about it really.

To debug (I hope you have a backup) you have to revert back to the previous version you had (6.0 as you say), then upgrade to 6.0.1 and post ./manage.py showmigrations. Then from that try to upgrade to 6.1 and again inspect showmigrations to see if everything is applied.

Note: in the case of traceback during migrate migrations have not been applied so it should be safe to attemp migrate again once you know which is the starting version and target version you are upgrading to.



来源:https://stackoverflow.com/questions/52979783/django-db-migrations-exceptions-inconsistentmigrationhistory-error-as-part-of-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!