[Django] #36985: Reversing CreateExtension throws error on non-postgresql database

28 views
Skip to first unread message

Django

unread,
Mar 13, 2026, 8:24:34 AMMar 13
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-----------------------+--------------------------------------------
Reporter: tahme | Type: Bug
Status: new | Component: contrib.postgres
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------+--------------------------------------------
When run on sqlite, a migration using postgres CreateExtension will skip
creating the extension. Trying to reverse the migration throws an error:
{{{
django.db.utils.OperationalError: no such table: pg_extension
}}}

I assume this is because CreateExtension.database_forwards checks
schema_editor.connection.vendor != "postgresql" but
CreateExtension.database_backwards does not.

Minimal migration example:
{{{
from django.db import migrations
from django.contrib.postgres.operations import CreateExtension

class Migration(migrations.Migration):
dependencies = []

operations = [
CreateExtension("pg_trgm")
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36985>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 16, 2026, 5:34:33 AMMar 16
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
----------------------------------+--------------------------------------
Reporter: Jori Niemi | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by Lakshya Prasad):

I can reproduce this issue locally. Reversing CreateExtension on a
non-PostgreSQL database raises an error. The operation should likely
be skipped when the connection vendor is not PostgreSQL.

I’d like to work on a fix if the ticket is accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:1>

Django

unread,
Mar 18, 2026, 2:33:19 PMMar 18
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
--------------------------------------+------------------------------------
Reporter: Jori Niemi | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):

* easy: 0 => 1
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization

Comment:

Ok, let's have this. Interestingly, this graceful skip in the forward
direction was only added for Django's own test suite in
36e90d1f45a13f53ce25fdc2d9c04433b835c9af.
--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:2>

Django

unread,
Mar 19, 2026, 2:23:02 AMMar 19
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Kasyap Pentamaraju):

* owner: (none) => Varun Kasyap Pentamaraju
* status: new => assigned

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

Django

unread,
Mar 22, 2026, 2:01:54 AMMar 22
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Lakshya Prasad):

Hi Varun, are you currently working on this ticket? If not, I’d be happy
to contribute a fix.
--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:4>

Django

unread,
Mar 22, 2026, 5:08:37 AMMar 22
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Varun Kasyap Pentamaraju):

Replying to [comment:4 Lakshya Prasad]:
> Hi Varun, are you currently working on this ticket? If not, I’d be happy
to contribute a fix.

Hi Lakshya,
I have a patch and will be submitting soon. Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:5>

Django

unread,
Mar 22, 2026, 12:31:44 PMMar 22
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Kasyap Pentamaraju):

* has_patch: 0 => 1

Comment:

https://github.com/django/django/pull/20964
--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:6>

Django

unread,
Mar 23, 2026, 4:08:33 AMMar 23
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Kasyap Pentamaraju):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:7>

Django

unread,
Mar 24, 2026, 2:07:37 AMMar 24
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Kasyap Pentamaraju):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:8>

Django

unread,
Mar 24, 2026, 8:56:10 AMMar 24
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:9>

Django

unread,
Mar 24, 2026, 8:56:46 AMMar 24
to django-...@googlegroups.com
#36985: Reversing CreateExtension throws error on non-postgresql database
-------------------------------------+-------------------------------------
Reporter: Jori Niemi | Owner: Varun
Type: | Kasyap Pentamaraju
Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: 6.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"b38cddf8f9d9dfe7a80e8d05c2295c69bdee68f0" b38cddf8]:
{{{#!CommitTicketReference repository=""
revision="b38cddf8f9d9dfe7a80e8d05c2295c69bdee68f0"
Fixed #36985 -- Skipped CreateExtension backwards operation on non-
PostgreSQL databases.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36985#comment:10>
Reply all
Reply to author
Forward
0 new messages