#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 Simon Charette):

 @Rico

 > I can't go back in time and ask the developer to put defaults on a NOT
 NULL field.

 You simply have to edit the migration that added the field and set a
 `default` and `preserve_default=False` to the `AddField` or `CreateModel`
 operation.

 @Daniel

 If `default` is defined on the field like in your example (`migration
 0003`) the migration framework will already knows that it must recreate
 the column with the provided default on the `RemoveField` reversal. I'm
 not sure the added complexity of `reverse_operation` is worth it.

 Maybe we could raise a warning/notice to users when generating a migration
 with a `RemoveField` for a field that doesn't define a default to suggest
 editing the migration that introduced the field to add a default?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23048#comment:6>
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.6e2e279a07c71f4ce8da181927fa7b3e%40djangoproject.com.

Reply via email to