Opened 5 years ago

Closed 5 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 Mariusz Felisiak, 5 years ago

Component: Migrationscontrib.postgres
Summary: Router support for CreateExtension operationsCreateExtension should check if migration is allowed.
Triage Stage: UnreviewedAccepted
Version: 2.1master

Agreed, we should check router.allow_migrate(schema_editor.connection.alias, app_label, **self.hints) in both CreateExtension.database_forwards() and database_backwards().

comment:2 by Hasan Ramezani, 5 years ago

Owner: changed from nobody to Hasan Ramezani
Status: newassigned

comment:3 by Hasan Ramezani, 5 years ago

Has patch: set
Last edited 5 years ago by Mariusz Felisiak (previous) (diff)

comment:4 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In ec292f26:

Fixed #31347 -- Checked allow_migrate() in CreateExtension operation.

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