[Django] #37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints

10 views
Skip to first unread message

Django

unread,
Apr 25, 2026, 6:46:25 PM (5 days ago) Apr 25
to django-...@googlegroups.com
#37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: New | Status: assigned
feature |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Per
[https://www.sqlite.org/releaselog/3_53_0.html#:~:text=features:-,Enhance%20ALTER%20TABLE%20to%20permit%20adding%20and%20removing%20NOT%20NULL%20and%20CHECK%20constraints.,-The
this release note]:

> Enhance ALTER TABLE to permit adding and removing NOT NULL and CHECK
constraints.

…we should be able to extend `django/db/backends/sqlite3/schema.py` to
avoid table rebuilds in those scenarios.
--
Ticket URL: <https://code.djangoproject.com/ticket/37068>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 25, 2026, 8:00:28 PM (5 days ago) Apr 25
to django-...@googlegroups.com
#37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted

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

Django

unread,
Apr 26, 2026, 1:47:24 AM (5 days ago) Apr 26
to django-...@googlegroups.com
#37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam Johnson:

Old description:

> Per
> [https://www.sqlite.org/releaselog/3_53_0.html#:~:text=features:-,Enhance%20ALTER%20TABLE%20to%20permit%20adding%20and%20removing%20NOT%20NULL%20and%20CHECK%20constraints.,-The
> this release note]:
>
> > Enhance ALTER TABLE to permit adding and removing NOT NULL and CHECK
> constraints.
>
> …we should be able to extend `django/db/backends/sqlite3/schema.py` to
> avoid table rebuilds in those scenarios.

New description:

Per
[https://www.sqlite.org/releaselog/3_53_0.html#:~:text=features:-,Enhance%20ALTER%20TABLE%20to%20permit%20adding%20and%20removing%20NOT%20NULL%20and%20CHECK%20constraints.,-The
this release note]:

> Enhance ALTER TABLE to permit adding and removing NOT NULL and CHECK
constraints.

…we should be able to extend `django/db/backends/sqlite3/schema.py` to
avoid table rebuilds in those scenarios.

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

Django

unread,
Apr 26, 2026, 6:26:47 PM (4 days ago) Apr 26
to django-...@googlegroups.com
#37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam Johnson):

(Side quest: updating Python to bundle SQLite 3.53.0+ on macOS and
Windows: https://github.com/python/cpython/issues/149029)
--
Ticket URL: <https://code.djangoproject.com/ticket/37068#comment:3>

Django

unread,
Apr 27, 2026, 1:42:18 AM (4 days ago) Apr 27
to django-...@googlegroups.com
#37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam Johnson):

Turns out there was a bug in this feature in SQLite 3.53.0 related to
`DROP CONSTRAINT`, fixed for the next release:
https://sqlite.org/forum/info/8bfbaec404
--
Ticket URL: <https://code.djangoproject.com/ticket/37068#comment:4>

Django

unread,
2:31 PM (7 hours ago) 2:31 PM
to django-...@googlegroups.com
#37068: Avoid table rebuild on SQLite 3.53.0+ for NOT NULL and CHECK constraints
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by JaeHyuckSa):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37068#comment:5>
Reply all
Reply to author
Forward
0 new messages