69 lines
1.9 KiB
MySQL
69 lines
1.9 KiB
MySQL
|
-- 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 matcher, public;
|
||
|
|
||
|
-- 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,
|
||
|
"driverDuration" INTEGER,
|
||
|
"driverDistance" INTEGER,
|
||
|
"passengerDuration" INTEGER,
|
||
|
"passengerDistance" INTEGER,
|
||
|
"waypoints" geography(LINESTRING),
|
||
|
"direction" geography(LINESTRING),
|
||
|
"fwdAzimuth" INTEGER NOT NULL,
|
||
|
"backAzimuth" INTEGER NOT NULL,
|
||
|
"seatsDriver" SMALLINT NOT NULL,
|
||
|
"seatsPassenger" SMALLINT NOT NULL,
|
||
|
"seatsUsed" 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")
|
||
|
);
|
||
|
|
||
|
-- 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");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE INDEX "ad_fwdAzimuth_idx" ON "ad"("fwdAzimuth");
|
||
|
|
||
|
-- CreateIndex
|
||
|
CREATE INDEX "direction_idx" ON "ad" USING GIST ("direction");
|