Opened 3 weeks ago
Closed 11 days ago
#36985 closed Cleanup/optimization (fixed)
Reversing CreateExtension throws error on non-postgresql database
| Reported by: | Jori Niemi | Owned by: | Varun Kasyap Pentamaraju |
|---|---|---|---|
| Component: | contrib.postgres | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
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")
]
Change History (10)
comment:1 by , 3 weeks ago
comment:2 by , 2 weeks ago
| Easy pickings: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Type: | Bug → Cleanup/optimization |
Ok, let's have this. Interestingly, this graceful skip in the forward direction was only added for Django's own test suite in 36e90d1f45a13f53ce25fdc2d9c04433b835c9af.
comment:3 by , 2 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
follow-up: 5 comment:4 by , 2 weeks ago
Hi Varun, are you currently working on this ticket? If not, I’d be happy to contribute a fix.
comment:5 by , 2 weeks ago
Replying to 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
comment:7 by , 12 days ago
| Patch needs improvement: | set |
|---|
comment:8 by , 12 days ago
| Patch needs improvement: | unset |
|---|
comment:9 by , 11 days ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
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.