'Updated Django version giving conflicting migrations in installed "contenttypes" app
I just upgraded from Django 2.2.6 to 4.0.3.
When I try to run my app locally, I see:
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
When I try to run the migrations, I get:
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'
If I try to run the merge command, I get:
ValueError: Could not find common ancestor of ['0001_initial', '0001_initial 2']
It seems to be coming from the built in contenttypes app:
python ./manage.py showmigrations contenttypes
contenttypes
[ ] 0001_initial 2
[X] 0001_initial
[X] 0002_remove_content_type_name
[ ] 0002_remove_content_type_name 2
How can I edit the migrations of a built in app? I'd like to remove the duplicate migrations so that they don't break my prod server when I deploy my app, but I can't find them anywhere. Please help me :)
Solution 1:[1]
Try to delete your virtualenv, install new one and install all packages. My problem has been fixed with this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shahinoo |
