[Django] #31347: Router support for CreateExtension operations

40 views
Skip to first unread message

Django

unread,
Mar 6, 2020, 12:41:01 AM3/6/20
to django-...@googlegroups.com
#31347: Router support for CreateExtension operations
----------------------------------------+------------------------
Reporter: Petr Přikryl | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.1
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 |
----------------------------------------+------------------------
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)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31347>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 6, 2020, 6:26:53 AM3/6/20
to django-...@googlegroups.com
#31347: CreateExtension should check if migration is allowed.
----------------------------------+------------------------------------

Reporter: Petr Přikryl | Owner: nobody
Type: Bug | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by felixxm):

* component: Migrations => contrib.postgres
* version: 2.1 => master
* stage: Unreviewed => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/31347#comment:1>

Django

unread,
Mar 6, 2020, 9:05:43 AM3/6/20
to django-...@googlegroups.com
#31347: CreateExtension should check if migration is allowed.
-------------------------------------+-------------------------------------
Reporter: Petr Přikryl | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned

Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/31347#comment:2>

Django

unread,
Mar 7, 2020, 5:12:22 PM3/7/20
to django-...@googlegroups.com
#31347: CreateExtension should check if migration is allowed.
-------------------------------------+-------------------------------------
Reporter: Petr Přikryl | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* has_patch: 0 => 1


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

Django

unread,
Mar 9, 2020, 5:34:43 AM3/9/20
to django-...@googlegroups.com
#31347: CreateExtension should check if migration is allowed.
-------------------------------------+-------------------------------------
Reporter: Petr Přikryl | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31347#comment:4>

Django

unread,
Mar 9, 2020, 7:34:26 AM3/9/20
to django-...@googlegroups.com
#31347: CreateExtension should check if migration is allowed.
-------------------------------------+-------------------------------------
Reporter: Petr Přikryl | Owner: Hasan
| Ramezani
Type: Bug | Status: closed
Component: contrib.postgres | Version: master
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: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"ec292f261d2390f692d5534ca85a427216bc4e39" ec292f26]:
{{{
#!CommitTicketReference repository=""
revision="ec292f261d2390f692d5534ca85a427216bc4e39"
Fixed #31347 -- Checked allow_migrate() in CreateExtension operation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31347#comment:5>

Reply all
Reply to author
Forward
0 new messages