id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 22277,migrations: a migration that depends on itself causing,Marcin Szamotulski ,nobody,"I have this list of migrations (migrations.loader line 196): {{{ for i in normal.items(): print(i) (('taggit', '0001_initial'), ) (('accounts', '0003_image'), ) (('social_feel', '0008_post_editors'), ) (('social_feel', '0009_post_authors'), ) (('social_feel', '0006_postimagecomment'), ) (('accounts', '0001_initial'), ) (('social_feel', '0010_postrevision_modified_by'), ) (('social_feel', '0005_postimage'), ) (('social_feel', '0003_postcomment'), ) (('social_feel', '0002_postauthor'), ) (('accounts', '0002_account'), ) (('social_feel', '0007_postrevision'), ) (('social_feel', '0001_initial'), ) (('social_feel', '0004_posteditor'), ) }}} When the loops (django.db.migrations.loader 196): {{{ for key, migration in normal.items(): for parent in migration.dependencies: }}} are building dependencies for `key = ('accounts', '0003_image')` there are no dependencies yet in `self.graph`, and the parent of this key is set to `('accounts', '__first__')`. Then this parent is resolved by the line 230: {{{ parent = list(self.graph.root_nodes(parent[0]))[0] }}} In pdb I can see that {{{ self.graph.root_nodes(parent[0]) returns: set([('accounts', '0003_image'), ('accounts', '0001_initial'), ('accounts', '0002_account')]) also `self.graph.dependencies` returns: {} }}} And then the parent (by the line 230) is set to `('accounts', '0003_image')`, i.e. it is equal to key. At the end of this loop iteration this line is executed: `self.graph.add_dependency(key, parent)` which adds ('accounts', '0003_image') as a dependency of itself. Later on I can see this error: {{{ Traceback (most recent call last): File ""./manage.py"", line 7, in execute_from_command_line(sys.argv) File ""/home/coot/webapps/social_feel/venv/src/django/django/core/management/__init__.py"", line 427, in execute_from_command_line utility.execute() File ""/home/coot/webapps/social_feel/venv/src/django/django/core/management/__init__.py"", line 419, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File ""/home/coot/webapps/social_feel/venv/src/django/django/core/management/base.py"", line 288, in run_from_argv self.execute(*args, **options.__dict__) File ""/home/coot/webapps/social_feel/venv/src/django/django/core/management/base.py"", line 337, in execute output = self.handle(*args, **options) File ""/home/coot/webapps/social_feel/venv/src/django/django/core/management/commands/makemigrations.py"", line 80, in handle loader.graph.project_state(), File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 138, in project_state for migration in self.forwards_plan(node): File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 53, in forwards_plan return self.dfs(node, lambda x: self.dependencies.get(x, set())) File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 119, in dfs return _dfs(start, get_children, []) File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 111, in _dfs results = _dfs(n, get_children, path) + results File ""/home/coot/webapps/social_feel/venv/src/django/django/db/migrations/graph.py"", line 103, in _dfs raise CircularDependencyError(path[path.index(start):] + [start]) django.db.migrations.graph.CircularDependencyError: [('accounts', '0003_image'), ('accounts', '0003_image')] }}}",Bug,closed,Migrations,dev,Normal,duplicate,,,Accepted,0,0,0,0,0,0