#23048: Add the ability to make RemoveField reversible for non-null fields
---------------------------------+------------------------------------
Reporter: Harris Lapiroff | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: 1.7-rc-1
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by Datamance):
Why was this closed as wontfix?
The provided "solutions" from the last couple of comments don't address
the fact that developers often take over projects that don't belong to
them initially; I can't go back in time and ask the developer to put
defaults on a NOT NULL field. Furthermore, solutions like inserting
AlterField in the migration itself clearly don't help when the migration
breaks precisely at RemoveField.
There is a completely reasonable fix to this and it's to add something
like a "reverse override" object in the migrations.RemoveField constructor
that allows you to change the field-adding behavior of the reversed query.
Something like
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
migrations.RemoveField(model_name="child", name="age_at_birth",
reversal_options={"null": True}),
}}}
}}}
Is a clean enough API and provides the necessary state to go backwards and
forwards cleanly.
--
Ticket URL: <https://code.djangoproject.com/ticket/23048#comment:4>
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/072.c25e9968067ed6cc9012a831f34e953b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.