#28000: Migration forces "DROP DEFAULT" SQL
-------------------------------------+-------------------------------------
     Reporter:  Matteo Pietro Russo  |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.9
     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 Matteo Pietro Russo):

 * status:  closed => new
 * resolution:  invalid =>


Comment:

 About default value, I read it in Django documentation:

 >> "The default value is used when new model instances are created and a
 value isn’t provided for the field."

 It's right if I use Django ORM, but I expect my field has rule I set in my
 model.

 You said that "Django uses database defaults to set values on existing
 rows in a table", but if I migrate my table adding default value,
 migration doesn't change anything: It doesn't set default value on
 existing rows, it' doesn't change field (it is nullable yet and i haven't
 default).


 {{{
 from django.db import models

 class PersonModel(models.Model):
     nickname = models.CharField(max_length=100, null=True)
 }}}

 If I change it:

 {{{
     nickname = models.CharField(default="noname", max_length=100,
 null=False)
 }}}

 makemigrations builds a migration with this operation:

 {{{
         migrations.AlterField(
             model_name='core_personmodel',
             name='nickname',
             field=models.CharField(default="noname", max_length=100,
 null=False),
         ),
 }}}

 If I execute migration:

 {{{

 Running migrations:
   Rendering model states... DONE
   Applying core.0004_migration... OK

 }}}

 but It's doesn't do anything.

--
Ticket URL: <https://code.djangoproject.com/ticket/28000#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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.e77887ede94ec7d374827b9a6791a27e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to