Opened 2 years ago

Last modified 2 years ago

#24870 new New feature

Create --update flag for makemigrations management command, mimicking South's one.

Reported by: Israel Saeta Pérez Owned by: nobody
Component: Migrations Version: master
Severity: Normal Keywords: migrations, south
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I was developing with South I was able to use the --update flag for the schemamigration management command (http://south.readthedocs.org/en/latest/commands.html#schemamigration) to refine the latest migration.

This was very convenient for iterative development. Could we have an equivalent of the --update flag for Django>=1.7 makemigrations?

(I've taken it from http://stackoverflow.com/questions/30487909/what-is-the-equivalent-of-souths-schemamigration-update-for-django-1-7)

Change History (4)

comment:1 Changed 2 years ago by Tim Graham

Cc: Andrew Godwin added

Andrew, could you offer your view.

comment:2 Changed 2 years ago by Andrew Godwin

It's certainly possible, though more complicated than before in South because of the multi-app nature of makemigrations - but also easier because of the ease of programatically parsing and writing migration files.

What this would be, in essence, is something that runs makemigrations and glues the first migration it makes for each app to the most recent one that already exists. The pain points I forsee are:

  • Migration files that have custom code (RunPython especially, but also any non-standard operation class) cannot be round-tripped through the parser and then out through the writer, so they could not be appended onto.
  • Dependencies would have to be checked to make sure this merging of the new migrations into old does not cause dependency loops.
  • It will occasionally have to just make new migrations anyway - it's more asking for a "best effort" attempt to make things work.

That said, I think it's not too complicated, and shares enough of these challenges with squashing (it's basically squashing the new migrations makemigrations creates into the last ones of the existing set), that we should aim to do it at some point.

comment:3 Changed 2 years ago by Tim Graham

Cc: Andrew Godwin removed
Triage Stage: UnreviewedAccepted

comment:4 Changed 2 years ago by Markus Holtermann

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