Postgres type "{field type}" is just a wrapper

I am using Django and postgres. My migration contains something like this:

db.create_table('location_locationlevel', (
        ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
        ('name_0', self.gf('django.db.models.fields.CharField')(max_length=75, null=True, blank=True)),
        ('name_1', self.gf('django.db.models.fields.CharField')(max_length=75, null=True, blank=True)),
        ('name_2', self.gf('django.db.models.fields.CharField')(max_length=75, null=True, blank=True)),
        ('name_3', self.gf('django.db.models.fields.CharField')(max_length=75, null=True, blank=True)),
        ('name_4', self.gf('django.db.models.fields.CharField')(max_length=100, null=True, blank=True)),
        ('geom', self.gf('django.contrib.gis.db.models.fields.MultiPolygonField')()),
    ))

When I start the migration, I get an error as shown below:

django.db.utils.DatabaseError: type "geometry" is only a shell
LINE 1: ...ABLE public.location_locationlevel ADD COLUMN geom geometry 
                                                         ^
QUERY:  ALTER TABLE public.location_locationlevel ADD COLUMN geom geometry 
CONTEXT:  PL/pgSQL function addgeometrycolumn(character varying,character varying,character varying,character varying,integer,character varying,integer)

Has anyone experienced something like this before, and what was the solution?

+4
source share
1 answer

In short, you need to reinstall postgis, perhaps just drop extension postgis;and create extension postgis;.

Longer explanation

Perhaps you can just skip this type, but I doubt it is, if you want to try, here is from 2.3:

CREATE TYPE public.geometry
   (INPUT=geometry_in,
       OUTPUT=geometry_out,
       RECEIVE=geometry_recv,
       SEND=geometry_send,
       TYPMOD_IN=geometry_typmod_in,
       TYPMOD_OUT=geometry_typmod_out,
       ANALYZE=geometry_analyze,
       CATEGORY='U', DEFAULT='',
       INTERNALLENGTH=-1, ALIGNMENT=double, STORAGE=MAIN);
ALTER TYPE public.geometry
  OWNER TO postgres;
COMMENT ON TYPE public.geometry
  IS 'postgis type: Planar spatial data type.';

As for shells, you can read more about them in the documentation .

: , , , , , - .

, Postgres , , .

geometry , postgis .

:

CREATE TYPE public.geometry
   (INPUT=shell_in,
       OUTPUT=shell_out,
       RECEIVE=-,
       SEND=-,
       ANALYZE=-,
       CATEGORY='P',
    PASSEDBYVALUE, DEFAULT='',
       INTERNALLENGTH=4, ALIGNMENT=int4, STORAGE=PLAIN);
ALTER TYPE public.geometry
  OWNER TO postgres;

, , :

CREATE OR REPLACE FUNCTION geometry_in(cstring)
    RETURNS geometry
    AS '$libdir/postgis-2.3','LWGEOM_in'
    LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;

geometry, , , .

+3

Source: https://habr.com/ru/post/1681266/


All Articles