Opened 9 years ago

Closed 9 years ago

#25945 closed Bug (fixed)

Referring to partially run squashed migrations

Reported by: Jarek Glowacki Owned by: Jarek Glowacki
Component: Migrations Version: dev
Severity: Normal Keywords: make squash migrations partially run dependencies
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jarek Glowacki)

Consider the migration tree defined by:

my_app/migrations/
0001_initial.py
0002_blah.py -> dep on 0001_initial
0001_initial_squashed_0002_blah.py -> replaces 0001_initial and 0002_blah
0003_ohnoes.py -> dep on ????

If we try to make 0003 depend on 0001_initial_squashed_0002_blah, then we get a NodeNotFoundError if the database is only up to 0001_initial: it is currently in the 'unsquashed reality' in which 0001_initial_squashed_0002_blah does not exist. Creating new databases from this setup does not raise any problems, nor does running the migrations on databases that aren't part-way through a squashed migration series since these will live in the 'squashed reality'.

If we try to make 0003 depend on 0002_blah, then things work fine in all cases.

However makemigrations chooses to point newly created migrations at the squashed migration 0001_initial_squashed_0002_blah rather than the last of the unsquashed ones 0002_blah, causing the problem described above and making it unobvious that new migrations should still point at the old replaced migrations up until the point at which the squashed migrations get transitioned to normal migrations.

Proposed solution:

Fully support listing the dependency both ways, as 0001_initial_squashed_0002_blah and as 0002_blah, using fancy logic to ensure valid references to inapplicable migrations are appropriately rerouted.

/ Patch
/ Pull Request

Change History (8)

comment:1 by Jarek Glowacki, 9 years ago

Summary: Unabled to refer to partially-run squashed migrations in newer migrations.Unable to refer to partially-run squashed migrations in newer migrations.

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Jarek Glowacki, 9 years ago

Description: modified (diff)
Keywords: make squash migrations added; squashmigrations removed
Summary: Unable to refer to partially-run squashed migrations in newer migrations.Makemigrations referring to squashed migrations

comment:4 by Jarek Glowacki, 9 years ago

Description: modified (diff)
Owner: changed from nobody to Jarek Glowacki
Status: newassigned
Summary: Makemigrations referring to squashed migrationsReferring to partially run squashed migrations

comment:5 by Jarek Glowacki, 9 years ago

Description: modified (diff)
Has patch: set

comment:6 by Tim Graham, 9 years ago

Patch needs improvement: set

Left comments for improvement on the pull request.

comment:7 by Markus Holtermann, 9 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin
Version: 1.9master

comment:8 by Markus Holtermann <info@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 509379a1:

Fixed #25945, #26292 -- Refactored MigrationLoader.build_graph()

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