Opened 9 years ago

Closed 3 years ago

#23953 closed Cleanup/optimization (fixed)

makemigrations generates "wrong" numbered migration file if squashed migrations are in place

Reported by: Markus Holtermann Owned by: Jacob Walls
Component: Migrations Version: 1.7
Severity: Normal Keywords:
Cc: Markus Holtermann Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


When an app has migrations 0001_initial and 0002_auto_20141202_1234 that are squashed to 0001_squashed_0002_auto_20141202_1234, a new call to makemigrations will generate a migration file called 0002_auto_20141202_2345 instead of 0003_auto_20141202_2345 which is quite irritating as long as 0002_auto_20141202_1234 is still around. It does make sense though when only 0001_squashed_0002_auto_20141202_1234 is left.

Although the latter case eventually hits every project, I'd prefer the former.

Change History (9)

comment:1 by Tim Graham, 9 years ago

Based on your logic, is it irritating to have 0001_initial and 0001_squashed_0002_auto_20141202_1234? Should the first squashed migration be 0003_...?

comment:2 by Markus Holtermann, 9 years ago

I don't think so. The squashed migration replaces 0001 to 0002, so sticking to 0001 seems fine to me.

Rethinking the initial thought about 0002_auto_20141202_2345 making sense if 0002_auto_20141202_1234 is gone an only the squashed migration is around: no, it doesn't make sense. The squashed migration says "0001 to 0002 is squashed". Thus continuing with 0003 seems to be the right choice.

comment:3 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

I guess it makes sense. If there is no way to reset the sequence of migrations, I wonder what happens when app has 10K migrations.

comment:4 by Jacob Walls, 3 years ago

Easy pickings: set
Has patch: set
Owner: changed from nobody to Jacob Walls
Status: newassigned

comment:5 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

comment:6 by Jacob Walls, 3 years ago

Patch needs improvement: unset

Thanks for speedy review. Of course let me know if this is moving in the wrong direction. Thanks.

comment:7 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 6e4ac28a:

Refs #23953 -- Added MigrationAutodetector.parse_number() tests.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 15683cd:

Fixed #23953 -- Made makemigrations continue number sequence for squashed migrations.

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