Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#30039 closed Bug (worksforme)

Inconsistency error after unapplying squash migration.

Reported by: Shehzad-Ahmed Owned by: nobody
Component: Migrations Version: 2.1
Severity: Normal Keywords: Squash migration, replaces, rolled back(UN-applied)
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Just for reminder: Migrations contain parent migrations called dependencies. So when an parent migration is rolled back all of its successors are also rolled back. For the consistency django make record of all applied and rolled back(unapplied) migrations. Now before any new migration is applied consistency is checked.

Just for reminder: In Case when a squash migration is created, a list inside it is maintained which tracks all migrations it replaced called replaces.

Problem: when a squash migration is rolled back all its replaces(which can be dependencies or depended on other migrations) are marked UN-applied but squash migration migration it-self does not record UN-applied. Since the operation of rolling back squash migration becomes completed. But Then when new migrate operation is performed, it causes inconsistency error e.g below:

"django.db.migrations.exceptions.InconsistentMigrationHistory: Migration compliance.0007_auto_20180329_1238_squashed_0026_auto_20180815_0741 is applied before its dependency survey.0092_prospectfarmerviewlinkcompliancelink on database 'default' ."

Change History (4)

comment:1 by Carlton Gibson, 6 years ago

Hi. Thanks for the report. Are you able to put together a small sample project demonstrating this?

comment:2 by Simon Charette, 6 years ago

Needs tests: set
Version 0, edited 6 years ago by Simon Charette (next)

comment:3 by Simon Charette, 6 years ago

Or at least tests to demonstrate the issue.

comment:4 by Carlton Gibson, 6 years ago

Component: Database layer (models, ORM)Migrations
Resolution: worksforme
Status: newclosed

OK, I can't reproduce this with the information provided.

In my testing all combinations of migrate, showmigrations, squashmigrations and so on are behaving as expected.

Happy to look at a sample project demonstrating an issue, but short of that I'm not sure we can say anything.

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