Skip to content

Commit

Permalink
feat(be): gtfs tables
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Dec 5, 2024
1 parent 0b2aa33 commit a9a8912
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- CreateTable
CREATE TABLE "GtfsRoute" (
"id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"shortName" TEXT NOT NULL,
"longName" TEXT,
"url" TEXT,
"color" TEXT,
"isNight" BOOLEAN,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "GtfsRoute_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "GtfsRouteStop" (
"id" TEXT NOT NULL,
"routeId" TEXT NOT NULL,
"directionId" TEXT NOT NULL,
"stopId" TEXT NOT NULL,
"stopSequence" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "GtfsRouteStop_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "GtfsRouteStop_routeId_directionId_stopId_stopSequence_key" ON "GtfsRouteStop"("routeId", "directionId", "stopId", "stopSequence");

-- AddForeignKey
ALTER TABLE "GtfsRouteStop" ADD CONSTRAINT "GtfsRouteStop_routeId_fkey" FOREIGN KEY ("routeId") REFERENCES "GtfsRoute"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
30 changes: 30 additions & 0 deletions apps/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@ model PlatformsOnRoutes {
@@unique([platformId, routeId])
}

model GtfsRoute {
id String @id
type String
shortName String
longName String?
url String?
color String?
isNight Boolean?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
GtfsRouteStop GtfsRouteStop[]
}

model GtfsRouteStop {
id String @id @default(uuid())
routeId String
route GtfsRoute @relation(fields: [routeId], references: [id])
directionId String
stopId String
stopSequence Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([routeId, directionId, stopId, stopSequence])
}

model Log {
id BigInt @id @default(autoincrement())
level LogLevel
Expand Down

0 comments on commit a9a8912

Please sign in to comment.