[Django] #21896: makemigrations warning "trying to add a non-nullable field" is raised even when the table is empty

34 views
Skip to first unread message

Django

unread,
Jan 29, 2014, 4:45:30 AM1/29/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
--------------------------------------+-------------------------
Reporter: kunitoki | Owner:
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: 1.7-alpha-1
Severity: Normal | Keywords: migrations
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+-------------------------
Probably doing a count() on the table would save a warning and user
interaction.

--
Ticket URL: <https://code.djangoproject.com/ticket/21896>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 30, 2014, 5:37:28 PM1/30/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
-------------------------------------+-------------------------------------
Reporter: kunitoki | Owner:
Type: | Status: new
Cleanup/optimization | Version:
Component: Migrations | 1.7-alpha-1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by anonymous):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/21896#comment:1>

Django

unread,
Feb 8, 2014, 3:13:28 PM2/8/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
-------------------------------------+-------------------------------------
Reporter: kunitoki | Owner:
Type: | Status: new
Cleanup/optimization | Version:
Component: Migrations | 1.7-alpha-1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/21896#comment:2>

Django

unread,
Feb 9, 2014, 7:57:36 AM2/9/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
-------------------------------------+-------------------------------------
Reporter: kunitoki | Owner:
Type: | Status: closed

Cleanup/optimization | Version:
Component: Migrations | 1.7-alpha-1
Severity: Normal | Resolution: invalid

Keywords: migrations | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by andrewgodwin):

* status: new => closed
* resolution: => invalid


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/21896#comment:3>

Django

unread,
Sep 28, 2014, 12:32:12 PM9/28/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
-------------------------------------+-------------------------------------
Reporter: kunitoki | Owner:
Type: | Status: closed
Cleanup/optimization | Version:
Component: Migrations | 1.7-alpha-1
Severity: Normal | Resolution: invalid
Keywords: migrations | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ashish1206):

Replying to [comment:3 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?

--
Ticket URL: <https://code.djangoproject.com/ticket/21896#comment:4>

Django

unread,
Sep 28, 2014, 12:34:18 PM9/28/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
-------------------------------------+-------------------------------------
Reporter: kunitoki | Owner:
Type: | Status: new

Cleanup/optimization | Version:
Component: Migrations | 1.7-alpha-1
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ashish1206):

* status: closed => new
* resolution: invalid =>


--
Ticket URL: <https://code.djangoproject.com/ticket/21896#comment:5>

Django

unread,
Sep 28, 2014, 2:01:22 PM9/28/14
to django-...@googlegroups.com
#21896: makemigrations warning "trying to add a non-nullable field" is raised even
when the table is empty
-------------------------------------+-------------------------------------
Reporter: kunitoki | Owner:
Type: | Status: closed

Cleanup/optimization | Version:
Component: Migrations | 1.7-alpha-1
Severity: Normal | Resolution:
Keywords: migrations | worksforme
Has patch: 0 | Triage Stage:
Needs tests: 0 | Unreviewed
Easy pickings: 0 | Needs documentation: 0

| Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ashish1206):

* status: new => closed
* resolution: => worksforme


--
Ticket URL: <https://code.djangoproject.com/ticket/21896#comment:6>

Reply all
Reply to author
Forward
0 new messages