versioned migration with sql source doesn't detect geometry column
-- FROM
CREATE TABLE "public"."loc" (
"id" serial NOT NULL,
PRIMARY KEY ("id")
);
-- TO
CREATE TABLE "public"."loc" (
"id" serial NOT NULL,
"location" geometry(point, 4326) NOT NULL,
PRIMARY KEY ("id")
);output: Schema is synced, no changes to be made.
// FROM
table "marker" {
schema = schema.public
column "id" {
type = serial
}
// TO
table "marker" {
schema = schema.public
column "id" {
type = serial
column "location" {
type = sql("geometry(Point,4326)")
}
}output: ALTER TABLE "public"."marker" ADD COLUMN "location" geometry(point,4326) NOT NULL...
and also when making diff with sql file as a desired state, dev database for diffing works very unexpectedly and it's very hard to work with, while hcl desired state just working.
when postgis extension is already installed on dev database i get this error:
Error: sql/migrate: taking database snapshot: sql/migrate: connected database is not clean: found table "spatial_ref_sys" in schema "public"
when I include CREATE EXTENSION IF NOT EXISTS postgis in the sql desired state to prevent above to happen I get:
Error: drop "spatial_ref_sys" table: pq: cannot drop table spatial_ref_sys because extension postgis requires it
and I had to put DROP extension PostGIS CASCADE; at the end of the file to get this finally working. but still when things go wrong and fail to apply, it doesn't drop the extension and it outputs the first not clean: found table "spatial_ref_sys" in schema "public" error again and it goes full circle. is there any recommended work flow with postgis or any other extensions with sql desired state?
please correct me if i'm getting anything wrong. thank you for the awesome work!
Source: ariga/atlas