Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27162 closed New feature (wontfix)

Move CreateExtension to django.db.backends.postgresql

Reported by: Claude Paroz Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The CreateExtension currently lives in django.contrib.postgres.operations. I think that it's a core functionality of the PostgreSQL backend and it should be usable without requiring contrib.postgres. PostGIS users might want to use it to add extensions in migrations. I therefore suggest to move it to a new location inside django.db.backends.postgresql. Backwards compatibility is kept as CreateExtension will still be imported from the same module it is defined in currently.

Change History (7)

comment:1 by Claude Paroz, 8 years ago

Has patch: set

comment:2 by Tim Graham, 8 years ago

I understand the purity behind the rationale, but the new import path (django.db.backends.postgresql.migrations.operations.CreateExtension) seems a bit unwieldy. I guess the pattern looks better for third-party backends that don't have "django.db.backends" in the import path. Also, I think this is the first time we would have users importing code directly from a database backend. I guess that's a more common pattern for third-party backends which may provide custom fields. It raises the question why we have contrib.postres instead of putting that in the backend though.

Is it impossible to import from the current location without adding contrib.postgres to INSTALLED_APPS?

comment:3 by Claude Paroz, 8 years ago

You are right, adding contrib.postgres to INSTALLED_APPS is not required, and this indeed makes my patch rather moot :-/
Do you agree about keeping the docs/ref/contrib/gis/install/postgis.txt and docs/ref/databases.txt additions from the patch (with paths corrected)?

comment:4 by Tim Graham, 8 years ago

Sure, adding the documentation is okay.

comment:5 by Tim Graham, 8 years ago

Resolution: wontfix
Status: newclosed

comment:6 by Claude Paroz <claude@…>, 8 years ago

In 6b54504:

Refs #27162 -- Complemented docs related to CreateExtension

Thanks Tim Graham for the review.

comment:7 by Tim Graham <timograham@…>, 8 years ago

In 0a81f54:

[1.10.x] Refs #27162 -- Complemented docs related to CreateExtension

Thanks Tim Graham for the review.

Backport of 6b54504e667da3f6bc53b887ffd7e8cc113a94b1 from master

Note: See TracTickets for help on using tickets.
Back to Top