#28273: Have a way to prevent adding columns with defaults in migrations
-------------------------------------+-------------------------------------
     Reporter:  Raphael Gaschignard  |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Migrations           |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * type:  Uncategorized => Cleanup/optimization
 * component:  Database layer (models, ORM) => Migrations


Comment:

 If a model field `default` is added after adding a nullable field, does it
 have the same issue? For example:

 migration one:
 adding `foo = models.NullBooleanField()`
 ALTER TABLE "t28273_test" ADD COLUMN "foo" boolean NULL;

 migration two:
 changing to `foo = models.NullBooleanField(default=True)`
 ALTER TABLE "t28273_test" ALTER COLUMN "foo" SET DEFAULT true;  # does
 this cause the backfill problem?
 ALTER TABLE "t28273_test" ALTER COLUMN "foo" DROP DEFAULT;

 I'm trying to think of how to solve this by structuring migrations
 appropriately because I'm not seeing another elegant way forward.

--
Ticket URL: <https://code.djangoproject.com/ticket/28273#comment:3>
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/062.09831b85856da7a0c40e1445b7496a4a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to