[Django] #23337: CircularDependencyError when squashing migrations

61 views
Skip to first unread message

Django

unread,
Aug 21, 2014, 5:46:01 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+----------------------
Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+----------------------
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')]

--
Ticket URL: <https://code.djangoproject.com/ticket/23337>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 21, 2014, 6:28:27 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+--------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by charettes):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:1>

Django

unread,
Aug 21, 2014, 6:41:47 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+--------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by Naddiseo):

* version: 1.7-rc-2 => 1.7-rc-3


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:2>

Django

unread,
Aug 21, 2014, 7:42:15 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
---------------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by charettes):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Managed to reproduce.

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:3>

Django

unread,
Aug 21, 2014, 9:26:06 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
---------------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by andrewgodwin):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:4>

Django

unread,
Aug 21, 2014, 10:18:55 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
---------------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-3
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Andrew Godwin <andrew@…>):

In [changeset:"459cfb523d8812081a623b29d0b8ab13bf87190a"]:
{{{
#!CommitTicketReference repository=""
revision="459cfb523d8812081a623b29d0b8ab13bf87190a"
Update squashmigration docs to also mention circ dep errs (refs #23337)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:5>

Django

unread,
Aug 21, 2014, 10:19:12 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by andrewgodwin):

* version: 1.7-rc-3 => master
* severity: Release blocker => Normal


--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:6>

Django

unread,
Aug 21, 2014, 10:19:15 PM8/21/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------

Comment (by Andrew Godwin <andrew@…>):

In [changeset:"fbe45076234b1509a574a78a0f2b2dda602836db"]:
{{{
#!CommitTicketReference repository=""
revision="fbe45076234b1509a574a78a0f2b2dda602836db"
[1.7.x] Update squashmigration docs to also mention circ dep errs (refs
#23337)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:7>

Django

unread,
Sep 9, 2014, 6:13:32 PM9/9/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Markush2010):

* cc: info+coding@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:8>

Django

unread,
Nov 26, 2014, 7:42:38 AM11/26/14
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Ian-Foote):

* cc: python@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:9>

Django

unread,
Jan 21, 2016, 12:34:36 PM1/21/16
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------

Reporter: Naddiseo | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by tarkatronic):

* cc: tarkatronic@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:10>

Django

unread,
Oct 19, 2017, 7:39:09 AM10/19/17
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
-------------------------------+------------------------------------
Reporter: Richard Eames | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Sergey Fedoseev):

* cc: Sergey Fedoseev (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:11>

Django

unread,
Aug 24, 2018, 10:15:15 AM8/24/18
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
-------------------------------+------------------------------------
Reporter: Richard Eames | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by danniranderis):

* cc: danniranderis (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:12>

Django

unread,
Mar 4, 2024, 11:18:33 AM3/4/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
-------------------------------+------------------------------------
Reporter: Richard Eames | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by bcail):

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?
--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:13>

Django

unread,
Mar 12, 2024, 4:21:55 PM3/12/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
-------------------------------+------------------------------------
Reporter: Richard Eames | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by bcail):

* cc: bcail (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:14>

Django

unread,
May 21, 2024, 6:37:40 AM5/21/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
-------------------------------+------------------------------------
Reporter: Richard Eames | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Sarah Boyce):

#35463 is a duplicate
--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:15>

Django

unread,
May 21, 2024, 7:54:42 AM5/21/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
-------------------------------+------------------------------------
Reporter: Richard Eames | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Gordon Wrigley):

* cc: Gordon Wrigley (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:16>

Django

unread,
Nov 20, 2024, 8:53:26 AM11/20/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------
Reporter: no | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Comment (by bcail):

[https://github.com/django/django/pull/18829 Here's] an example PR that
checks for circular dependencies when creating squashed migrations, and
raises an error if there's a circular dependency. Is that a helpful
direction? Would it be better to leave the squashed migration with the
circular dependency, but print a warning for the user?
--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:17>

Django

unread,
Nov 21, 2024, 10:29:41 AM11/21/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------
Reporter: no | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Comment (by Gordon Wrigley):

We have adopted a (rather complex) process to produce dual level squashes.
The guts of the idea is instead of squashing each app to a single
migration we squash to two migrations. The first one creates all the
tables, the second one creates all the FK's. This resolves all circularity
issues.
--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:18>

Django

unread,
Nov 21, 2024, 10:42:29 AM11/21/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------
Reporter: no | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Comment (by bcail):

OK, do you want to open a thread on the forum, pitch that idea to the
community, and see what people think?
--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:19>

Django

unread,
Nov 25, 2024, 5:19:30 AM11/25/24
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------
Reporter: no | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Comment (by Gordon Wrigley):

Replying to [comment:19 bcail]:
> OK, do you want to open a thread on the forum, pitch that idea to the
community, and see what people think?

We're going to run it again in a few weeks, maybe after that. I will feel
more comfortable sharing the scripts we use if we've just recently used
them.
--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:20>

Django

unread,
Feb 25, 2025, 7:45:53 AMFeb 25
to django-...@googlegroups.com
#23337: CircularDependencyError when squashing migrations
----------------------------+------------------------------------
Reporter: no | Owner: bcail
Type: Bug | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------------------
Changes (by Jacob Walls):

* has_patch: 0 => 1
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* owner: nobody => bcail
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/23337#comment:21>
Reply all
Reply to author
Forward
0 new messages