web-dev-qa-db-ja.com

Django1.9で検出された競合する移行を修正

Django-dynamic-model リポジトリを更新してDjango 1.9をサポートしました。このエラーが発生しました:

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'

実行後python manage.py makemigrations --merge、別のエラーが発生しました:

 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']). 

解決策を見つけるのを手伝ってください。

9
Seenu S

移行には「ストレート」な依存関係チェーンが必要です。つまり、移行0003は移行0002に依存し、0002は0001に依存する必要があります。

これを0003_third.pyで次のように定義する必要があります。

class Migration(migrations.Migration):
    dependencies = [
        ('modulename', '0002_second'),
    ]
2
PHZ.fi-Pharazon