-- CreateExtension CREATE EXTENSION IF NOT EXISTS "postgis"; -- Required to use postgis extension : -- set the search_path to both public (where is postgis) AND the current schema SET search_path TO territory, public; -- CreateTable CREATE TABLE "territory" ( "uuid" UUID NOT NULL, "name" TEXT NOT NULL, "shape" geometry NOT NULL, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "territory_pkey" PRIMARY KEY ("uuid") ); -- CreateIndex CREATE UNIQUE INDEX "territory_name_key" ON "territory"("name"); CREATE INDEX "shape_idx" ON "territory" USING GIST ("shape");