-- CreateEnum CREATE TYPE "Frequency" AS ENUM ('PUNCTUAL', 'RECURRENT'); -- CreateTable CREATE TABLE "ad" ( "uuid" UUID NOT NULL, "userUuid" UUID NOT NULL, "driver" BOOLEAN NOT NULL, "passenger" BOOLEAN NOT NULL, "frequency" "Frequency" NOT NULL, "fromDate" DATE NOT NULL, "toDate" DATE NOT NULL, "monTime" TIMESTAMPTZ, "tueTime" TIMESTAMPTZ, "wedTime" TIMESTAMPTZ, "thuTime" TIMESTAMPTZ, "friTime" TIMESTAMPTZ, "satTime" TIMESTAMPTZ, "sunTime" TIMESTAMPTZ, "monMargin" INTEGER NOT NULL, "tueMargin" INTEGER NOT NULL, "wedMargin" INTEGER NOT NULL, "thuMargin" INTEGER NOT NULL, "friMargin" INTEGER NOT NULL, "satMargin" INTEGER NOT NULL, "sunMargin" INTEGER NOT NULL, "seatsDriver" SMALLINT NOT NULL, "seatsPassenger" SMALLINT NOT NULL, "strict" BOOLEAN NOT NULL, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "ad_pkey" PRIMARY KEY ("uuid") ); -- CreateTable CREATE TABLE "address" ( "uuid" UUID NOT NULL, "adUuid" UUID NOT NULL, "position" SMALLINT NOT NULL, "lon" DOUBLE PRECISION NOT NULL, "lat" DOUBLE PRECISION NOT NULL, "name" TEXT, "houseNumber" TEXT, "street" TEXT, "locality" TEXT, "postalCode" TEXT, "country" TEXT, "countryCode" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "address_pkey" PRIMARY KEY ("uuid") ); -- AddForeignKey ALTER TABLE "address" ADD CONSTRAINT "address_adUuid_fkey" FOREIGN KEY ("adUuid") REFERENCES "ad"("uuid") ON DELETE CASCADE ON UPDATE CASCADE;