#25453: makemigrations suggestion seems to go against best practices
----------------------------+--------------------
     Reporter:  piquadrat   |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.8
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 When creating a migration that makes a formerly nullable field non-
 nullable, `makemigrations` has these suggestions:

 {{{
 You are trying to change the nullable field 'foo' on bar to non-nullable
 without a default; we can't do that (the database needs something to
 populate existing rows).
 Please select a fix:
  1) Provide a one-off default now (will be set on all existing rows)
  2) Ignore for now, and let me handle existing rows with NULL myself (e.g.
 adding a RunPython or RunSQL operation in the new migration file before
 the AlterField operation)
  3) Quit, and let me add a default in models.py
 }}}

 The second option seems to suggest to add the `RunPython` operation in the
 same migration file as the `AlterField` operation, which is against best
 practices of splitting schema- and data-migrations.

 This seems to be somewhat related to #24630, which updated the
 documentation to show how to split up the migration (albeit for a slightly
 different use case). I'm not sure how the output from `makemigrations`
 could be worded better, but it could e.g. link to the updated docs.

--
Ticket URL: <https://code.djangoproject.com/ticket/25453>
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/052.eec4fa8ed54914a09dc452308f022247%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to