Opened 10 years ago

Last modified 6 days ago

#23337 new Bug

CircularDependencyError when squashing migrations

Reported by: Richard Eames Owned by: nobody
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: info+coding@…, python@…, tarkatronic@…, Sergey Fedoseev, danniranderis, bcail Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Project layout:

.
├── cheese
│   ├── init.py
│   ├── migrations
│   │   └── init.py
│   └── models.py (model Cheese, links to eggs.Store and spam.Employee)
├── djtest
│   ├── basemodel.py
│   ├── init.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── eggs
│   ├── init.py
│   ├── migrations
│   │   └── init.py
│   └── models.py (model Store, links to spam.Employee)
├── manage.py
└── spam

├── init.py
├── migrations
│   └── init.py
└── models.py (model Employee, links to itself and eggs.Store; model Eggs, links to spam.Employee and cheese.Cheese)

Issue the following commands for the attached project:

$ python manage.py makemigrations
$ manage squashmigrations cheese 0003
$ manage squashmigrations eggs 0002

The following is raised:

django.db.migrations.graph.CircularDependencyError: [('spam', '0001_initial'), ('cheese', '0001_squashed_0003_cheese_updated_by'), ('spam', '0001_initial')]

Attachments (1)

djtest.zip (5.0 KB ) - added by Richard Eames 10 years ago.
Test project

Download all attachments as: .zip

Change History (15)

by Richard Eames, 10 years ago

Attachment: djtest.zip added

Test project

comment:1 by Simon Charette, 10 years ago

Thanks for the detailed report. Just to make sure, did you reproduce against 1.7-rc-2 or 1.7-rc-3?

comment:2 by Richard Eames, 10 years ago

Version: 1.7-rc-21.7-rc-3

It was 1.7-rc-3, The option wasn't available when I reported.

comment:3 by Simon Charette, 10 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Managed to reproduce.

comment:4 by Andrew Godwin, 10 years ago

Ah, yes, squashing migrations does occasionally result in circular dependencies and there's no way we can solve this in 1.7 (it requires some specialised coding we just don't have). I'll add a note to the docs about this and bump it down from Release Blocker to a more general issue we need to solve next release.

comment:5 by Andrew Godwin <andrew@…>, 10 years ago

In 459cfb523d8812081a623b29d0b8ab13bf87190a:

Update squashmigration docs to also mention circ dep errs (refs #23337)

comment:6 by Andrew Godwin, 10 years ago

Severity: Release blockerNormal
Version: 1.7-rc-3master

comment:7 by Andrew Godwin <andrew@…>, 10 years ago

In fbe45076234b1509a574a78a0f2b2dda602836db:

[1.7.x] Update squashmigration docs to also mention circ dep errs (refs #23337)

comment:8 by Markus Holtermann, 10 years ago

Cc: info+coding@… added

comment:9 by Ian Foote, 9 years ago

Cc: python@… added

comment:10 by Joey Wilhelm, 8 years ago

Cc: tarkatronic@… added

comment:11 by Sergey Fedoseev, 6 years ago

Cc: Sergey Fedoseev added

comment:12 by danniranderis, 6 years ago

Cc: danniranderis added

comment:13 by bcail, 2 weeks ago

It looks like the first squashmigrations command for the cheese app results in a circular dependency, so a migrate or makemigrations command fails with the CircularDependencyError (even without squashing migrations in the eggs app).

Would it be helpful to add a check in the squashmigrations command to look at its output and throw an error instead of writing out a squashed migration that causes a CircularDependencyError?

comment:14 by bcail, 6 days ago

Cc: bcail added
Note: See TracTickets for help on using tickets.
Back to Top