Opened 9 years ago
Closed 2 years ago
#24870 closed New feature (fixed)
Create --update flag for makemigrations management command, mimicking South's one.
Reported by: | Israel Saeta Pérez | Owned by: | David Wobrock |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | migrations, south |
Cc: | David Wobrock | 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
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 (14)
comment:1 by , 9 years ago
Cc: | added |
---|
comment:2 by , 9 years ago
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 by , 9 years ago
Cc: | removed |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 9 years ago
Version: | 1.8 → master |
---|
comment:5 by , 3 years ago
Cc: | added |
---|---|
Has patch: | set |
Owner: | changed from | to
Status: | new → assigned |
Hello,
I tried to tackle this ticket as I believe it would still be a pretty useful addition to makemigrations
.
During development, I often see developers struggle with the manual steps to re-generate a migration while they are still iterating on their approach.
Here is the approach I've taken https://github.com/django/django/pull/15669
I tried to keep the implementation rather straightforward.
The main drawback I see is that it will add a new edge case when one updates a migration that has already been applied. This will create a bit of confusion, as it will become more tedious to undo the updated migration, since the reverse operations will try to undo things that weren't initially applied.
comment:6 by , 3 years ago
Patch needs improvement: | set |
---|
comment:7 by , 2 years ago
Patch needs improvement: | unset |
---|
comment:8 by , 2 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
comment:9 by , 2 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | unset |
comment:10 by , 2 years ago
Patch needs improvement: | set |
---|
comment:11 by , 2 years ago
Patch needs improvement: | unset |
---|
comment:12 by , 2 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Andrew, could you offer your view.