#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 djsmedes):
It seems like the clearest interface and most general solution would be to
allow manually specifying the reverse operation as an entire object. With
`preserve_default=False` you can then set a default on a field that was
nullable. For example:
{{{
# migration 0003
...
operations = [
migrations.AddField(
model_name='invitation',
name='first_name',
field=models.TextField(default=''),
preserve_default=False,
),
]
...
# migration 0004
...
operations = [
migrations.RemoveField(
model_name='invitation',
name='first_name',
reverse_operation=migrations.AddField( # <-- this is what I am
proposing
...
field=models.TextField(default=''),
preserve_default=False,
...
),
),
...
}}}
This could be applied to `AlterField` as well I would think.
--
Ticket URL: <https://code.djangoproject.com/ticket/23048#comment:5>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/072.6514665f28041922b0a75863cfcf0c82%40djangoproject.com.