Opened 6 years ago
Closed 6 years ago
#31347 closed Bug (fixed)
CreateExtension should check if migration is allowed.
| Reported by: | Petr Přikryl | Owned by: | Hasan Ramezani |
|---|---|---|---|
| Component: | contrib.postgres | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hi, I have problem migrating some 3rd party database with Django migrations. I have used router for controlling which apps are allowed to be migrated on this database. But I have problem with HStoreExtension operation because these operations don't check if they are allowed. And because I have limited rights and I am controlling only my schema on that database I will get error while installing hstore.
Source of trouble:
https://github.com/django/django/blob/master/django/contrib/postgres/operations.py#L18
Work-around/proposal for CreateExtension class:
class RoutingHStoreExtension(HStoreExtension):
def database_forwards(self, app_label, schema_editor, from_state, to_state):
if not router.allow_migrate(schema_editor.connection.alias, app_label):
return
return super().database_forwards(app_label, schema_editor, from_state, to_state)
Change History (5)
comment:1 by , 6 years ago
| Component: | Migrations → contrib.postgres |
|---|---|
| Summary: | Router support for CreateExtension operations → CreateExtension should check if migration is allowed. |
| Triage Stage: | Unreviewed → Accepted |
| Version: | 2.1 → master |
comment:2 by , 6 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 6 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Agreed, we should check
router.allow_migrate(schema_editor.connection.alias, app_label, **self.hints)in bothCreateExtension.database_forwards()anddatabase_backwards().