CREATE TABLE IF NOT EXISTS geohub.dataset
(
id character varying COLLATE pg_catalog."default" NOT NULL,
url character varying COLLATE pg_catalog."default" NOT NULL,
is_raster boolean NOT NULL,
license character varying COLLATE pg_catalog."default",
bounds geometry(Polygon,4326) NOT NULL,
createdat timestamp with time zone NOT NULL,
updatedat timestamp with time zone,
name character varying COLLATE pg_catalog."default",
description character varying COLLATE pg_catalog."default",
created_user character varying(100) COLLATE pg_catalog."default" NOT NULL,
updated_user character varying(100) COLLATE pg_catalog."default",
access_level integer NOT NULL DEFAULT 3,
CONSTRAINT dataset_pkey PRIMARY KEY (id)
)
When I used introspect, introspect correctly generated initial SQL like below
CREATE TABLE IF NOT EXISTS "geohub"."dataset" (
"id" varchar PRIMARY KEY NOT NULL,
"url" varchar NOT NULL,
"is_raster" boolean NOT NULL,
"license" varchar,
"bounds" geometry(Polygon,4326) NOT NULL, # introspect correctly generated current schema
"createdat" timestamp with time zone NOT NULL,
"updatedat" timestamp with time zone,
"name" varchar,
"description" varchar,
"created_user" varchar(100) NOT NULL,
"updated_user" varchar(100),
"access_level" integer DEFAULT 3 NOT NULL
);
and, the below is schema.ts generated by introspect. This has no issue.
However, when I used pnpm drizzle-kit:generate, it created the wrong SQL like below. Then when I push migrations to my local database, drizzle create the table with point geometry without specified srid 4326 even schema.ts is configured correctly.
CREATE TABLE IF NOT EXISTS "geohub"."dataset" (
"id" varchar PRIMARY KEY NOT NULL,
"url" varchar NOT NULL,
"is_raster" boolean NOT NULL,
"license" varchar,
"bounds" geometry(point) NOT NULL, # changed polygon to point, and dropped srid
"createdat" timestamp with time zone NOT NULL,
"updatedat" timestamp with time zone,
"name" varchar,
"description" varchar,
"created_user" varchar(100) NOT NULL,
"updated_user" varchar(100),
"access_level" integer DEFAULT 3 NOT NULL
);
Expected behavior
migration should correctly create Polygon geometry SQL with srid as introspect does.
What version of
drizzle-orm
are you using?0.33.0
What version of
drizzle-kit
are you using?0.24.2
Describe the Bug
I have a table in the database like the below
When I used
introspect
, introspect correctly generated initial SQL like belowand, the below is schema.ts generated by introspect. This has no issue.
However, when I used
pnpm drizzle-kit:generate
, it created the wrong SQL like below. Then when I push migrations to my local database, drizzle create the table with point geometry without specified srid 4326 even schema.ts is configured correctly.Expected behavior
migration should correctly create Polygon geometry SQL with srid as
introspect
does.Environment & setup
I am using drizzle in svelte-kit
drizzle.config.ts is as follow
my working branch is at https://github.com/UNDP-Data/geohub/pull/4142