我刚从Django 2.2.6升级到4.0.3。
当我尝试在本地运行我的应用程序时,我看到:
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
当我试图运行迁移时,我得到:
CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0001_initial 2, 0002_remove_content_type_name, 0002_remove_content_type_name 2 in contenttypes; 0001_initial 2, 0002_alter_permission_name_max_length 2, 0003_alter_user_email_max_length 2, 0004_alter_user_username_opts 2, 0005_alter_user_last_login_null 2, 0006_require_contenttypes_0002 2, 0007_alter_validators_add_error_messages 2, 0008_alter_user_username_max_length 2, 0009_alter_user_last_name_max_length 2, 0010_alter_group_name_max_length 2, 0011_update_proxy_permissions 2, 0012_alter_user_first_name_max_length, 0012_alter_user_first_name_max_length 2 in auth; 0001_initial, 0001_initial 2 in sessions; 0001_initial 2, 0002_logentry_remove_auto_add 2, 0003_logentry_add_action_flag_choices, 0003_logentry_add_action_flag_choices 2 in admin).
To fix them run 'python manage.py makemigrations --merge'
如果我试图运行merge命令,我会得到:
ValueError: Could not find common ancestor of ['0001_initial', '0001_initial 2']
它似乎来自内置的内容类型应用程序:
python ./manage.py showmigrations contenttypes
contenttypes
[ ] 0001_initial 2
[X] 0001_initial
[X] 0002_remove_content_type_name
[ ] 0002_remove_content_type_name 2
如何编辑内置应用程序的迁移?我想删除重复迁移,以便在部署我的应用程序时不会损坏我的prod服务器,但在任何地方都找不到。请帮助我:)
发布于 2022-04-20 14:31:34
尝试删除您的virtualenv,安装新的,并安装所有软件包。我的问题已经解决了。
https://stackoverflow.com/questions/71527253
复制相似问题