2023-05-04 10:07:53 +00:00
|
|
|
-- CreateEnum
|
|
|
|
CREATE TYPE "Frequency" AS ENUM ('PUNCTUAL', 'RECURRENT');
|
|
|
|
|
|
|
|
-- CreateEnum
|
|
|
|
CREATE TYPE "AddressType" AS ENUM ('HOUSE_NUMBER', 'STREET_ADDRESS', 'LOCALITY', 'VENUE', 'OTHER');
|
|
|
|
|
2023-05-03 15:31:26 +00:00
|
|
|
-- CreateTable
|
|
|
|
CREATE TABLE "ad" (
|
|
|
|
"uuid" UUID NOT NULL,
|
|
|
|
"userUuid" UUID NOT NULL,
|
2023-05-04 10:07:53 +00:00
|
|
|
"driver" BOOLEAN,
|
|
|
|
"passenger" BOOLEAN,
|
|
|
|
"frequency" "Frequency" NOT NULL DEFAULT 'RECURRENT',
|
2023-05-03 15:31:26 +00:00
|
|
|
"fromDate" DATE NOT NULL,
|
2023-05-04 10:07:53 +00:00
|
|
|
"toDate" DATE,
|
|
|
|
"monTime" TIMESTAMPTZ,
|
|
|
|
"tueTime" TIMESTAMPTZ,
|
|
|
|
"wedTime" TIMESTAMPTZ,
|
|
|
|
"thuTime" TIMESTAMPTZ,
|
|
|
|
"friTime" TIMESTAMPTZ,
|
|
|
|
"satTime" TIMESTAMPTZ,
|
|
|
|
"sunTime" TIMESTAMPTZ,
|
|
|
|
"monMargin" INTEGER,
|
|
|
|
"tueMargin" INTEGER,
|
|
|
|
"wedMargin" INTEGER,
|
|
|
|
"thuMargin" INTEGER,
|
|
|
|
"friMargin" INTEGER,
|
|
|
|
"satMargin" INTEGER,
|
|
|
|
"sunMargin" INTEGER,
|
|
|
|
"seatsDriver" SMALLINT,
|
|
|
|
"seatsPassenger" SMALLINT,
|
2023-05-03 15:31:26 +00:00
|
|
|
"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,
|
2023-05-04 10:07:53 +00:00
|
|
|
"position" SMALLINT NOT NULL,
|
2023-05-03 15:31:26 +00:00
|
|
|
"lon" DOUBLE PRECISION NOT NULL,
|
|
|
|
"lat" DOUBLE PRECISION NOT NULL,
|
2023-05-04 10:07:53 +00:00
|
|
|
"houseNumber" TEXT,
|
|
|
|
"street" TEXT,
|
|
|
|
"locality" TEXT,
|
|
|
|
"postalCode" TEXT,
|
|
|
|
"country" TEXT,
|
|
|
|
"type" "AddressType" DEFAULT 'OTHER',
|
2023-05-03 15:31:26 +00:00
|
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
|
|
|
CONSTRAINT "address_pkey" PRIMARY KEY ("uuid")
|
|
|
|
);
|
|
|
|
|
|
|
|
-- CreateIndex
|
|
|
|
CREATE INDEX "ad_driver_idx" ON "ad"("driver");
|
|
|
|
|
|
|
|
-- CreateIndex
|
|
|
|
CREATE INDEX "ad_passenger_idx" ON "ad"("passenger");
|
|
|
|
|
|
|
|
-- CreateIndex
|
|
|
|
CREATE INDEX "ad_fromDate_idx" ON "ad"("fromDate");
|
|
|
|
|
|
|
|
-- CreateIndex
|
|
|
|
CREATE INDEX "ad_toDate_idx" ON "ad"("toDate");
|
2023-05-04 08:05:23 +00:00
|
|
|
|
|
|
|
-- AddForeignKey
|
2023-05-04 10:07:53 +00:00
|
|
|
ALTER TABLE "address" ADD CONSTRAINT "address_adUuid_fkey" FOREIGN KEY ("adUuid") REFERENCES "ad"("uuid") ON DELETE CASCADE ON UPDATE CASCADE;
|