Changes between Initial Version and Version 1 of Ticket #28975, comment 7


Ignore:
Timestamp:
Jan 10, 2018, 7:46:54 AM (7 years ago)
Author:
sphrak

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28975, comment 7

    initial v1  
    11This issue is currently stalled while waiting on response here: https://groups.google.com/forum/#!topic/django-developers/EjouxahkqUc
    2 
    3 
    4 Replying to [ticket:28975 sphrak]:
    5 > Hello,
    6 > I have found an issue with the documentation and/or the behaivor of the postgis extension create method.
    7 >
    8 > **Background**
    9 > I am trying to migrate my app that uses the postgis extension inside a docker container. I do create the extension beforehand as superuser since I dont intend to run the database connection as a postgres superuser.
    10 >
    11 > **Problem**
    12 > As per the documentation found here: https://docs.djangoproject.com/en/2.0/ref/contrib/gis/install/postgis/
    13 >
    14 >
    15 > I find it confusing that the documentation states "The command is run during the migrate process." and "An alternative is to use a migration operation in your project:". Because what seems to be the problem is that even if you remove the create extension statement from the migration file, it still runs regardless - rendering the option to put the create extension statement inside the migration file somewhat redundant and probably not very useful.
    16 >
    17 > **Possible solution**
    18 > Ideally the behaivor would be only create extension if its in a migration file and if its not - its the users concern to create it however it see fit.
    19 >
    20 > The relevant part is this:
    21 > {{{
    22 > testing.api |   File "/usr/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 26, in prepare_database
    23 > testing.api |     cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis")
    24 > }}}
    25 >
    26 > Full trace:
    27 > {{{
    28 > testing.api | POSTGRES: I'm still down. Standby.
    29 > testing.api |                               List of databases
    30 > testing.api |    Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges   
    31 > testing.api | -----------+----------+----------+---------+---------+-----------------------
    32 > testing.api |  postgres  | postgres | UTF8     | C       | C.UTF-8 |
    33 > testing.api |  template0 | postgres | UTF8     | C       | C.UTF-8 | =c/postgres          +
    34 > testing.api |            |          |          |         |         | postgres=CTc/postgres
    35 > testing.api |  template1 | postgres | UTF8     | C       | C.UTF-8 | =c/postgres          +
    36 > testing.api |            |          |          |         |         | postgres=CTc/postgres
    37 > testing.api |  testing   | postgres | UTF8     | C       | C.UTF-8 | =Tc/postgres         +
    38 > testing.api |            |          |          |         |         | postgres=CTc/postgres+
    39 > testing.api |            |          |          |         |         | testing=CTc/postgres
    40 > testing.api | (4 rows)
    41 > testing.api |
    42 > testing.api | POSTGRES: I'm up, I'm up, I'm f***** up - but I'm up
    43 > testing.api | Collecting selenium==3.3.1 (from -r /app/src/core/requirements/testing.txt (line 1))
    44 > testing.api |   Downloading selenium-3.3.1-py2.py3-none-any.whl (930kB)
    45 > testing.api | Collecting django-debug-toolbar==1.8 (from -r /app/src/core/requirements/testing.txt (line 2))
    46 > testing.api |   Downloading django_debug_toolbar-1.8-py2.py3-none-any.whl (205kB)
    47 > testing.api | Requirement already satisfied: Django>=1.8 in /usr/lib/python3.6/site-packages (from django-debug-toolbar==1.8->-r /app/src/core/requirements/testing.txt (line 2))
    48 > testing.api | Collecting sqlparse>=0.2.0 (from django-debug-toolbar==1.8->-r /app/src/core/requirements/testing.txt (line 2))
    49 > testing.api |   Downloading sqlparse-0.2.4-py2.py3-none-any.whl
    50 > testing.api | Requirement already satisfied: pytz in /usr/lib/python3.6/site-packages (from Django>=1.8->django-debug-toolbar==1.8->-r /app/src/core/requirements/testing.txt (line 2))
    51 > testing.api | Installing collected packages: selenium, sqlparse, django-debug-toolbar
    52 > testing.api | Successfully installed django-debug-toolbar-1.8 selenium-3.3.1 sqlparse-0.2.4
    53 > testing.api | Traceback (most recent call last):
    54 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
    55 > testing.api |     return self.cursor.execute(sql)
    56 > testing.api | psycopg2.ProgrammingError: permission denied to create extension "postgis"
    57 > testing.api | HINT:  Must be superuser to create this extension.
    58 > testing.api |
    59 > testing.api |
    60 > testing.api | The above exception was the direct cause of the following exception:
    61 > testing.api |
    62 > testing.api | Traceback (most recent call last):
    63 > testing.api |   File "manage.py", line 22, in <module>
    64 > testing.api |     execute_from_command_line(sys.argv)
    65 > testing.api |   File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    66 > testing.api |     utility.execute()
    67 > testing.api |   File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    68 > testing.api |     self.fetch_command(subcommand).run_from_argv(self.argv)
    69 > testing.api |   File "/usr/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    70 > testing.api |     self.execute(*args, **cmd_options)
    71 > testing.api |   File "/usr/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
    72 > testing.api |     output = self.handle(*args, **options)
    73 > testing.api |   File "/usr/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 77, in handle
    74 > testing.api |     connection.prepare_database()
    75 > testing.api |   File "/usr/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 26, in prepare_database
    76 > testing.api |     cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis")
    77 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    78 > testing.api |     return super().execute(sql, params)
    79 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    80 > testing.api |     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
    81 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    82 > testing.api |     return executor(sql, params, many, context)
    83 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    84 > testing.api |     return self.cursor.execute(sql, params)
    85 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    86 > testing.api |     raise dj_exc_value.with_traceback(traceback) from exc_value
    87 > testing.api |   File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
    88 > testing.api |     return self.cursor.execute(sql)
    89 > testing.api | django.db.utils.ProgrammingError: permission denied to create extension "postgis"
    90 > testing.api | HINT:  Must be superuser to create this extension.
    91 > }}}
Back to Top