#20656 closed Uncategorized (needsinfo)
test db spatial extentsion not created when using new postgis 2.0 "CREATE EXTENSION postgis;" method
Reported by: | monkut | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | flavio.curella@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Following the directions here:
I created my database using the new "CREATE EXTENSION postgis;" method and then attempted to run tests using the standard, manage.py test, but it appears that test does not properly add the necessary postgis extensions and errors with:
DatabaseError: type "geometry" does not exist LINE 7: "center" geometry(POINT,3122),
In addition, I attempted to define the POSTGIS_VERSION in my settings.py file thinking this might just be undocumented, but even after adding this, the same error above is still seen.
https://docs.djangoproject.com/en/1.5/ref/contrib/gis/testing/#postgis-version
I guess the work around is to revert to using the create postgis template method.
It would be nice if testing was supported when the "CREATE EXTENTSION" method is used, but if not supported, at least update the docs to mention testing can't be done when this method is used.
Change History (11)
comment:1 by , 11 years ago
Summary: | test db not created when using new postgis 2.0 "CREATE EXTENSION postgis;" method → test db spatial extentsion not created when using new postgis 2.0 "CREATE EXTENSION postgis;" method |
---|
comment:2 by , 11 years ago
Component: | Uncategorized → GIS |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 11 years ago
comment:4 by , 11 years ago
Did you also run CREATE EXTENSION postgis_topology;
? I remember that error message, IIRC the reason was not creating the postgis_topology extension, or maybe is was having a template database for PostGIS 1.5. The latter case is easy to check - if you have postgis template, rename it so that Django won't see it.
comment:5 by , 11 years ago
Component: | GIS → Uncategorized |
---|---|
Triage Stage: | Accepted → Unreviewed |
no, "CREATE EXTENSION postgis_topology;" was not run on the initial database.
comment:6 by , 11 years ago
just browsed https://github.com/django/django/commit/fbd1df8e16fc17a5d73f36136298c20b8ec3d618 mentioned in #19152, I don't remember if it's required, but the CREATE extension statement appears to be missing a ";" (semicolon).
cursor.execute("CREATE EXTENSION postgis")
comment:7 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Hi Monkut,
I just tried creating a simple project, and my tests run fine.
I've created my database using:
$ createdb mydb $ psql mydb psql (9.2.2) Type "help" for help. mydb=# CREATE EXTENSION postgis; CREATE EXTENSION
I've tested using manage.py test myapp
on Django 1.5 and Django Trunk (commit 99b467f272da9). For future reference, my Postgresql version was 9.2.2 and POSTGIS was 2.0.2.
comment:8 by , 11 years ago
Component: | Uncategorized → GIS |
---|
comment:9 by , 11 years ago
Component: | GIS → Uncategorized |
---|
ok, it's probably an error on my part. I've already migrated back to the template method, but if I hit the problem again I'll try to get more details.
Thanks!
comment:10 by , 11 years ago
Cc: | added |
---|
comment:11 by , 10 years ago
I ran into this problem and fixed it by dropping the PostGIS template as Anssi suggested in comment 4:
postgres=# UPDATE pg_database SET datistemplate='false' WHERE datname='template_postgis'; UPDATE 1 postgres=# DROP DATABASE template_postgis; DROP DATABASE
#19152 was supposed to fix this issue. I have no such setup at hand currently, but it should be nice to understand why that fix failed somewhere.