2015-06-26 11 views
5

Ich arbeite mit einer Postgres-Datenbank und der Postgis-Erweiterung. Jetzt, nach Django Upgrade 1.8, erhalte ich diesen Fehler während manage.py migrate ausgeführt wird:Postgis-Migrationsfehler nach dem Upgrade auf Django 1.8

Traceback (most recent call last): 
    File "./manage.py", line 13, in <module> 
    execute_from_command_line(sys.argv) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line 
    utility.execute() 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute 
    output = self.handle(*args, **options) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 91, in handle 
    connection.prepare_database() 
    File "/my-project/env/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 39, in prepare_database 
    cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis") 
    File "/my-project/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute 
    return super(CursorDebugWrapper, self).execute(sql, params) 
    File "/my-project/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "/my-project/env/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/my-project/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute 
    return self.cursor.execute(sql) 
django.db.utils.ProgrammingError: type "spheroid" already exists 

Versionen

Ich verwende Postgres.app auf OS X

  • psql (9.3. 4)
  • SELECT PostGIS_version(); postgis_version 2.1 USE_GEOS=1 USE_PROJ=1USE_STATS=1
  • Django 1.8.2

Antwort

3

Ok, ich habe es gelöst.

Zuerst habe ich postgres und postgis upgraden, indem ich Postgres.app durch die neuste Version ersetzt und die brew Pakete aktualisiert habe. Danach bekam ich folgende Fehlermeldung:

Traceback (most recent call last): 
    File "./manage.py", line 13, in <module> 
    execute_from_command_line(sys.argv) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line 
    utility.execute() 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute 
    output = self.handle(*args, **options) 
    File "/my-project/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 91, in handle 
    connection.prepare_database() 
    File "/my-project/env/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 39, in prepare_database 
    cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis") 
    File "/my-project/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute 
    return super(CursorDebugWrapper, self).execute(sql, params) 
    File "/my-project/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "/my-project/env/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/my-project/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute 
    return self.cursor.execute(sql) 
django.db.utils.InternalError: PostGIS is already installed in schema 'public', uninstall it first 

Dann führte ich ein "Hard-Upgrade", wie hier http://postgis.net/docs/manual-2.1/postgis_installation.html#upgrading erklärt

Alle Schritte

  1. pg_dump -U $PGUSER -Fc -b -v -f "your_db.backup" your_db
  2. (inkl Hart-Upgrade.)
  3. psql -U $PGUSER -d postgres -c "DROP DATABASE your_db;"
  4. brew uninstall postgresql93 && brew install postgresql oder brew upgrade postgresql
  5. brew uninstall postgis15 && brew install postgis oder brew upgrade postgis
  6. ersetzen Postgres.app mit neuesten
  7. pip uninstall psycopg2 && pip install psycopg2
  8. psql -U $PGUSER -d postgres -c "CREATE DATABASE your_db;"
  9. psql -U $PGUSER -d your_db -c "CREATE EXTENSION postgis;"
  10. /usr/local/share/postgis/postgis_restore.pl your_db.backup | psql -U $PGUSER your_db 2> errors.txt
+0

ich das gleichen Problem bekam bei der Bewegung 1,9 bis django. Diese Lösung hat für mich funktioniert. Allerdings musste ich die Schritte 3 bis 6 nicht ausführen. –

Verwandte Themen