[Django] #29063: Replacement Migrations not being executed because of unapplied migrations should raise a warning.

8 views
Skip to first unread message

Django

unread,
Jan 25, 2018, 9:27:53 AM1/25/18
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
------------------------------------------------+------------------------
Reporter: Julian Schneider | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
In Line 205-208 in django/db/migrations/loader.py replacement migrations
(created with squash) are checked if they can be applied. If any of the to
be replaced migrations isn't already applied the replacement migration is
not added to the nodes list.

This leads to the fact that if some of the migrations are removed or not
completely applied before the squash is added and there is a dependency on
the replacement migration, the user gets a 'NodeNotFoundError' where the
replacement migration that is not being applied because of line 206 is the
missing one.

This is very confusing to the user, raising a warning in line 208 would
inform the user that the squashed migration can not be applied because not
all the 'child' migrations are applied.

Had to debug into that to figure that out.

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

Django

unread,
Feb 3, 2018, 3:41:17 PM2/3/18
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
--------------------------------------+------------------------------------
Reporter: Julian | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 1.9
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 Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Jun 6, 2021, 11:12:58 PM6/6/21
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
-------------------------------------+-------------------------------------
Reporter: Julian | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 1.9

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 Jacob Walls):

* owner: nobody => Jacob Walls
* status: new => assigned


Comment:

Somewhat similar to #23556, I think we can raise a more informative
`NodeNotFoundError`. Should have a patch soon, just need to toy with
whether backward migrations are also a problem.

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

Django

unread,
Jul 15, 2021, 12:49:29 PM7/15/21
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
-------------------------------------+-------------------------------------
Reporter: Julian | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/14643 PR]

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

Django

unread,
Jul 27, 2021, 5:32:34 AM7/27/21
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
-------------------------------------+-------------------------------------
Reporter: Julian | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 1.9

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 Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


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

Django

unread,
Jul 28, 2021, 2:34:51 PM7/28/21
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
-------------------------------------+-------------------------------------
Reporter: Julian | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: Migrations | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


Comment:

On the PR Mariusz demonstrated several examples having to do with this
ticket's description where the error messages are sufficiently
informative. However, I think my test case is related to the original
poster's scenario (although it is hard to be certain), and shows Django
raising an improvable `NodeNotFoundError`.

Glad to give it another look, though, if you think I'm misreading the
original poster's use case. (To that end, Julian, I would be grateful if
you would be able to take a look at my suggested patch.)

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

Django

unread,
Aug 2, 2021, 11:20:59 AM8/2/21
to django-...@googlegroups.com
#29063: Replacement Migrations not being executed because of unapplied migrations
should raise a warning.
----------------------------+---------------------------------------
Reporter: Julian | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------
Changes (by Jacob Walls):

* type: Cleanup/optimization => Bug


Comment:

After Mariusz helpfully enumerated scenarios where the current messaging
is sufficient, we found really only a single case with an improvable
`NodeNotFoundError`, and I agree it would be better to just fix the
failure point than invest energy in a patch changing the exception
message:

[https://github.com/django/django/pull/14727 New PR]

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

Django

unread,
Aug 2, 2021, 11:37:49 AM8/2/21
to django-...@googlegroups.com
#29063: Naming an incompletely applied squashed migration as a migration target
fails with bare NodeNotFoundError

----------------------------+---------------------------------------
Reporter: Julian | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------

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

Django

unread,
Aug 4, 2021, 3:58:52 AM8/4/21
to django-...@googlegroups.com
#29063: Naming an incompletely applied squashed migration as a migration target
fails with bare NodeNotFoundError
----------------------------+---------------------------------------------

Reporter: Julian | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Migrations | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Aug 4, 2021, 6:23:39 AM8/4/21
to django-...@googlegroups.com
#29063: Naming an incompletely applied squashed migration as a migration target
fails with bare NodeNotFoundError
----------------------------+---------------------------------------------
Reporter: Julian | Owner: Jacob Walls
Type: Bug | Status: closed
Component: Migrations | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"910ecd1b8df7678f45c3d507dde6bcb1faafa243" 910ecd1]:
{{{
#!CommitTicketReference repository=""
revision="910ecd1b8df7678f45c3d507dde6bcb1faafa243"
Fixed #29063 -- Fixed migrate crash when specifying a name of partially
applied squashed migrations.
}}}

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

Reply all
Reply to author
Forward
0 new messages