[Django]-Type geometry does not exist after CREATE EXTENSION postgis

2👍

CREATE EXTENSION is permanent for the database you are running it in. It creates objects in a given (or the current default) schema. Per documentation:

schema_name

The name of the schema in which to install the extension’s objects, given that the extension allows its contents to be relocated.
The named schema must already exist. If not specified, and the
extension’s control file does not specify a schema either, the current
default object creation schema is used.

Remember that the extension itself is not considered to be within any schema: extensions have unqualified names that must be unique
database-wide. But objects belonging to the extension can be within
schemas.

Check which schemas are involved in psql:

\connect mydb
\x 
\dx postgis*

The schemas used must be in your current search_path (or you’d have to schema-qualify all references).
I am not sure migrate includes additional schemas or extensions at all.
Most probably, this is an issue with the search_path

0👍

I needed to give my database user permission to access the postgis schema. I ran the following while connected to my django database and then migrate was able to run successfully.

GRANT ALL PRIVILEGES ON SCHEMA postgis TO username;

0👍

For me grant usage on schema <postgis-install-schema> to <myschema> solved it (<postgis-install-schema> was public in my case).

(grant all privileges as suggested from TechnoConserve may be too much for security reasons)

Leave a comment