Opened 9 years ago
Closed 9 years ago
#26594 closed Cleanup/optimization (duplicate)
Text in migration prompt is scary and (slightly) wrong
Reported by: | Mike Lissner | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.9 |
Severity: | Normal | Keywords: | terror |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I just did the following:
- 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.
Note:
See TracTickets
for help on using tickets.
Sorry for the scare. Duplicate of #26075.