2023-05-04 10:07:53 +00:00
|
|
|
-- CreateEnum
|
|
|
|
CREATE TYPE "Frequency" AS ENUM ('PUNCTUAL', 'RECURRENT');
|
|
|
|
|
2023-05-03 15:31:26 +00:00
|
|
|
-- CreateTable
|
|
|
|
CREATE TABLE "ad" (
|
|
|
|
"uuid" UUID NOT NULL,
|
|
|
|
"userUuid" UUID NOT NULL,
|
2023-05-10 12:37:00 +00:00
|
|
|
"driver" BOOLEAN NOT NULL,
|
|
|
|
"passenger" BOOLEAN NOT NULL,
|
|
|
|
"frequency" "Frequency" NOT NULL,
|
2023-05-03 15:31:26 +00:00
|
|
|
"fromDate" DATE NOT NULL,
|
2023-05-10 12:37:00 +00:00
|
|
|
"toDate" DATE NOT NULL,
|
2023-06-20 14:50:55 +00:00
|
|
|
"seatsProposed" SMALLINT NOT NULL,
|
|
|
|
"seatsRequested" SMALLINT NOT NULL,
|
2023-05-11 09:17:47 +00:00
|
|
|
"strict" BOOLEAN NOT NULL,
|
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")
|
|
|
|
);
|
|
|
|
|
2023-07-25 14:52:41 +00:00
|
|
|
-- CreateTable
|
|
|
|
CREATE TABLE "schedule_item" (
|
|
|
|
"uuid" UUID NOT NULL,
|
|
|
|
"adUuid" UUID NOT NULL,
|
|
|
|
"day" INTEGER NOT NULL,
|
|
|
|
"time" TIME(4) NOT NULL,
|
|
|
|
"margin" INTEGER NOT NULL,
|
|
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
|
|
|
CONSTRAINT "schedule_item_pkey" PRIMARY KEY ("uuid")
|
|
|
|
);
|
|
|
|
|
2023-05-03 15:31:26 +00:00
|
|
|
-- CreateTable
|
2023-06-20 14:50:55 +00:00
|
|
|
CREATE TABLE "waypoint" (
|
2023-05-03 15:31:26 +00:00
|
|
|
"uuid" UUID NOT NULL,
|
|
|
|
"adUuid" UUID NOT NULL,
|
2023-05-04 10:07:53 +00:00
|
|
|
"position" SMALLINT NOT NULL,
|
2023-06-23 09:37:26 +00:00
|
|
|
"lon" DECIMAL(9,6) NOT NULL,
|
|
|
|
"lat" DECIMAL(8,6) NOT NULL,
|
2023-05-10 12:37:00 +00:00
|
|
|
"name" TEXT,
|
2023-05-04 10:07:53 +00:00
|
|
|
"houseNumber" TEXT,
|
|
|
|
"street" TEXT,
|
|
|
|
"locality" TEXT,
|
|
|
|
"postalCode" TEXT,
|
2023-05-15 15:00:05 +00:00
|
|
|
"country" TEXT NOT NULL,
|
2023-05-03 15:31:26 +00:00
|
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
2023-06-20 14:50:55 +00:00
|
|
|
CONSTRAINT "waypoint_pkey" PRIMARY KEY ("uuid")
|
2023-05-03 15:31:26 +00:00
|
|
|
);
|
|
|
|
|
2023-07-25 14:52:41 +00:00
|
|
|
-- AddForeignKey
|
|
|
|
ALTER TABLE "schedule_item" ADD CONSTRAINT "schedule_item_adUuid_fkey" FOREIGN KEY ("adUuid") REFERENCES "ad"("uuid") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
|
2023-05-04 08:05:23 +00:00
|
|
|
-- AddForeignKey
|
2023-06-20 14:50:55 +00:00
|
|
|
ALTER TABLE "waypoint" ADD CONSTRAINT "waypoint_adUuid_fkey" FOREIGN KEY ("adUuid") REFERENCES "ad"("uuid") ON DELETE CASCADE ON UPDATE CASCADE;
|