1
votes

As I was changing my models.py and migrating, I got an error message saying:

python manage.py makemigrations project_profile

CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0033_auto_20180217_0912, 0036_auto_20180217_0927 in project_profile). To fix them run 'python manage.py makemigrations --merge'

So, when I tried to follow the instructions, I got another error that one of my tables that the merged migration is now depending on do not exist anymore (I renamed it). Interestingly enough, this renaming took place during the merge operation. So, really Django should have known about it in the first place.

To resolve the situation, I deleted prior migrations up to and including the migrations that was not applied, the one that caused all the headache. I tried to makemigrations and migrate again. But, Django now throws another error saying some of the models it wants to create in the database already exist. Obviously, I do not want to delete those tables and loose all that information to appease Django. So, I had to resort to some hacking solutions and actually change those tables manually and do a fake migration in order to stop Django from complaining.

Having said all of that, I feel like there should be a more logical way about this. How do I resolve migrations during the merging?

1

1 Answers

1
votes

I had the same issue, Then I was able to solve this by deleting the migrations file that django pointed out and starts with name auto. It occurred 2-3 times before it finally gave up and finally worked.

Alternatively you can django-dbbackup or django-import-export packages to backup the tables then clean your database and migrations. Then you can restore them back to the same state once migrations are stable.

Sources

dbbackup : https://django-dbbackup.readthedocs.io/en/stable/

import-export : https://django-import-export.readthedocs.io/en/latest/index.html