17

I updated django-dynamic-model repository to support Django 1.9. I got this error:

CommandError: 

Conflicting migrations detected; multiple leaf nodes in the migration
graph: (0001_initial, 0002_auto__add_field_dynamicschemafield_extra in
dynamicmodel).
To fix them run 'python manage.py makemigrations --merge'

After running python manage.py makemigrations --merge, I got another error:

 File "/local/lib/python2.7/sitepackages/django/core/management/__init__.py",  
line 353, in execute_from_command_line
utility.execute()

 File "/local/lib/python2.7/sitepackages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)

 File 
"/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)

File 
"/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)

File 
"/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 97, in handle
return self.handle_merge(loader, conflicts)

File 
   "/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 216, in handle_merge
 raise ValueError("Could not find common ancestor of %s" % migration_names)


 ValueError: Could not find common ancestor of set([u'0001_initial', u'0002_auto__add_field_dynamicschemafield_extra']). 

Help me to find the solution.

Kevin Christopher Henry
  • 46,175
  • 7
  • 116
  • 102
Seenu S
  • 3,381
  • 6
  • 30
  • 45

2 Answers2

14

The migrations need to have "straight" dependency chain, i.e. migration 0003 needs to depend on migration 0002, and 0002 on 0001.

You need to define this in the 0003_third.py like this:

class Migration(migrations.Migration):
    dependencies = [
        ('modulename', '0002_second'),
    ]
PHZ.fi-Pharazon
  • 1,479
  • 14
  • 15
0

Seems like you have injected models of other applications.

Define TARGET_APP in your migrations, seems like migrations loader can't correctly identify target app.

Dmitry Shilyaev
  • 713
  • 4
  • 10
  • What is `TARGET_APP`? I'm on Django 1.8 and tried to explicitly give the app name after the `--merge` but that didn't help either – Csaba Toth Jun 06 '17 at 23:00
  • 1
    I see, `TARGET_APP` is a variable within a migration file, and not a parameter for the migrate script https://stackoverflow.com/questions/29575802/django-migration-file-in-an-other-app – Csaba Toth Jun 06 '17 at 23:03