Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django migrations conflict multiple leaf nodes in the migration graph

With Django 1.11.22 I'm trying to run migrations

python manage.py migrate
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration base.0036_auto_20190227_1226 is applied before its dependency base.0027_auto_20170801_1228_squashed_0037_auto_20190222_1347 on database 'default'.

My first try to solve this was

sudo -u postgres psql -d albatros -c \
"DELETE FROM django_migrations WHERE name = '0036_auto_20190227_1226' AND app = 'base'"

In the hope of deleting the migration from the migration table would fix it. Unfortunately I'm now getting:

CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0037_auto_20190222_1347, 0036_auto_20190227_1226 in base).
To fix them run 'python manage.py makemigrations --merge'

When tryin makemigrations --merge it does not find any migrations to merge. This is what showmigrations looks like:

 ./manage.py  showmigrations base
base
 [X] 24_initial
 [X] 24_to_26
 [X] 26_to_27
 [X] 0027_auto_20170801_1228
 [X] 0028_resourcebase_is_approved
 [X] 0029_auto_20171114_0341
 [X] 0030_auto_20180309_0833
 [X] 0031_auto_20180309_0837
 [X] 0032_auto_20180329_1844
 [X] 0033_auto_20180330_0951
 [X] 0034_auto_20180606_1543
 [X] 0035_resourcebase_dirty_state
 [ ] 0036_auto_20190227_1226
 [ ] 0036_auto_20190129_1433
 [ ] 0037_auto_20190222_1347

Can one say how to correctly apply the migrations and solve the multiple leaf nodes error?

like image 663
Anatol Avatar asked Nov 17 '25 21:11

Anatol


1 Answers

In this 2 migration files (0037_auto_20190222_1347, 0036_auto_20190227_1226) you have same dependencies, check them. They seems like a list with tuple in it

dependencies = [
    ('round', '0008_auto_20200116_0752'),
]

You need to manually write "0036_auto_20190227_1226" into 0037_auto_20190222_1347 file dependencies variable.

like image 174
Abdumalik Kochkorov Avatar answered Nov 19 '25 14:11

Abdumalik Kochkorov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!