#24109: Provide a way to mark a migration operation as elidable when squashing
---------------------------------------+------------------------
Reporter: carljm | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
The vast majority of my RunPython/RunSQL operations are data migrations
related to an enclosing pair of schema migrations: for instance, add a new
field, migrate data to it from an old field, then remove the old field.
Such operations are generally safe to elide when squashing: in the
squashed and optimized list of operations, old-field should never exist at
all, and thus there is no need for a migration to move data from old-field
to new-field. But the migration system doesn't know this, so it
(correctly) refuses to optimize across the RunPython/RunSQL, causing
schema-altering migrations to be preserved that shouldn't be (i.e.
creation and removal of old-field won't be optimized away, because of the
intervening RunPython/RunSQL).
It's possible to manually remove such RunPython/RunSQL operations before
squashing, but it's a pain to review the whole history for such cases and
manually remove them.
I would find it useful to have an attribute like `elidable` or
`optimize_across` on migration operations (at least on `RunPython` and
`RunSQL`), settable via a kwarg to the constructor, which would default to
`False` (preserving the current behavior), but if set to `True` would mark
the migration as "safe to elide and optimize across". This would never be
set to `True` by the autodetector, it would only ever be set manually by
the user.
Thoughts?
--
Ticket URL: <https://code.djangoproject.com/ticket/24109>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.1de341c9d832b3f6b78e5dde1844893d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.