[Django] #24795: Migrations fail to apply with postgis 2.0 on remote database

7 views
Skip to first unread message

Django

unread,
May 13, 2015, 10:40:32 AM5/13/15
to django-...@googlegroups.com
#24795: Migrations fail to apply with postgis 2.0 on remote database
----------------------------+--------------------
Reporter: zejn | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
Hi,

Problem lies here:
https://github.com/django/django/blob/1.8.1/django/contrib/gis/db/backends/postgis/base.py

Beginning with 1.8, the logic to prepare database for test setup has been
refactored and the prepare_database() now runs before any migration, not
only before tests. This is important, because this now runs even in
production.

Since 1.8 supports both Postgis 1.5 and 2.0, the code tries to access the
default database, with PostgreSQL this is "postgres" to check the postgis
1.5 template database, specified in POSTGIS_TEMPLATE, actually exists.

I have a production setup using PostgreSQL with Postgis 2.0 on a separate
database server. The only accessible database (in pg_hba.conf) for my
database user is the database the Django uses. Since code tries to access
the database the user does not have access to (postgres), the whole
migration process fails.

See
https://github.com/django/django/commit/bac7664f274be834a09e037331889959f04a75e7
for the relevant changes.

The bug isn't present in master, because the failing query is only used
for Postgis 1.5, which is not supported anymore in master, see
https://github.com/zejn/django/commit/26996e2d55719deb0a0b85c642c88658c929106c

I came up with a simple solution, but it's a bit implicit, see
https://github.com/zejn/django/commit/acf81f0fe30bff8aa709e37ea10cf63061db4fbc

For the time being I've patched Django.

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

Django

unread,
May 13, 2015, 11:33:28 AM5/13/15
to django-...@googlegroups.com
#24795: Migrations fail to apply with postgis 2.0 on remote database
------------------------+--------------------------------------
Reporter: zejn | Owner: nobody
Type: Bug | Status: closed
Component: GIS | Version: 1.8
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------+--------------------------------------
Changes (by claudep):

* status: new => closed
* needs_docs: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

This is a duplicate of #24791. Looks like this `nodb_connection` was not
such a good idea.

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

Reply all
Reply to author
Forward
0 new messages