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 anonymous, 11 years ago

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.

comment:2 by Aymeric Augustin, 11 years ago

I agree with the first comment: this sounds fragile. I'm leaving the final say to Andrew.

comment:3 by Andrew Godwin, 11 years ago

Resolution: invalid
Status: newclosed

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.

in reply to:  3 comment:4 by Ashish1206, 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?

After deleting the previous models and again using makemigrations it works now.I don't know what happened!

Last edited 10 years ago by Ashish1206 (previous) (diff)

comment:5 by Ashish1206, 10 years ago

Resolution: invalid
Status: closednew

comment:6 by Ashish1206, 10 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top