Opened 11 years ago
Closed 10 years ago
#21896 closed Cleanup/optimization (worksforme)
makemigrations warning "trying to add a non-nullable field" is raised even when the table is empty
Reported by: | Lucio Asnaghi | Owned by: | |
---|---|---|---|
Component: | Migrations | Version: | 1.7-alpha-1 |
Severity: | Normal | Keywords: | migrations |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Probably doing a count() on the table would save a warning and user interaction.
Change History (6)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
I agree with the first comment: this sounds fragile. I'm leaving the final say to Andrew.
follow-up: 4 comment:3 by , 11 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
We don't know what size the table might be in the future, so we have to raise this during makemigrations
; you might make the migration on a dev box with no entries and then run it on a production box with millions of rows, so it has to stay. Marking INVALID.
comment:4 by , 10 years ago
Replying to andrewgodwin:
We don't know what size the table might be in the future, so we have to raise this during
makemigrations
; you might make the migration on a dev box with no entries and then run it on a production box with millions of rows, so it has to stay. Marking INVALID.
I am using django 1.7 and getting the same warning for fields when I use makemigrations
on dev server.How to fix this?
comment:5 by , 10 years ago
Resolution: | invalid |
---|---|
Status: | closed → new |
comment:6 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I don't think we can silence the warning in that case since it may be empty in dev, but then when you come to apply the migration in production it might not work. Much safer to always warn to make sure you've considered the possibility, as long as there's a way to ignore it if you're sure it'll be fine.