- Converted a field to non-nullable in my model.
- Created a migration
- Had the following interaction:
{{{
You are trying to change the nullable field 'pacer_case_id' on docket 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.
because you added a RunPython or RunSQL operation to handle NULL values in
a previous data migration)
3) Quit, and let me add a default in models.py
Select an option: 1
Please enter the default value now, as valid Python
The datetime and django.utils.timezone modules are available, so you can
do e.g. timezone.now()
>>> ''
}}}
You can see that I entered (blank) for all the null values.
Next, I went to the production server and started deploying the migration.
This is when I wondered, wait, did I just set *every* value to blank, or
just the null ones?
And I went and read the prompt from a moment ago and saw:
{{{
Provide a one-off default now (will be set on all existing rows)
}}}
(will be set on all existing rows)
WILL BE SET ON ALL EXISTING ROWS.
== WILL BE SET ON ALL EXISTING ROWS! ==
----
Well, that terrified me for a moment.
I suggest we change this to say:
{{{
(will be set on all existing null-value rows)
}}}
Or something to that effect.
--
Ticket URL: <https://code.djangoproject.com/ticket/26594>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
Sorry for the scare. Duplicate of #26075.
--
Ticket URL: <https://code.djangoproject.com/ticket/26594#comment:1>