intermediate stops
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Location" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Cable" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"identifier" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"notes" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
"startLocationId" INTEGER NOT NULL,
|
||||
"endLocationId" INTEGER NOT NULL,
|
||||
CONSTRAINT "Cable_startLocationId_fkey" FOREIGN KEY ("startLocationId") REFERENCES "Location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Cable_endLocationId_fkey" FOREIGN KEY ("endLocationId") REFERENCES "Location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Core" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"color" TEXT NOT NULL,
|
||||
"notes" TEXT,
|
||||
"cableId" INTEGER NOT NULL,
|
||||
CONSTRAINT "Core_cableId_fkey" FOREIGN KEY ("cableId") REFERENCES "Cable" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CableStop" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"order" INTEGER NOT NULL,
|
||||
"cableId" INTEGER NOT NULL,
|
||||
"locationId" INTEGER NOT NULL,
|
||||
CONSTRAINT "CableStop_cableId_fkey" FOREIGN KEY ("cableId") REFERENCES "Cable" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "CableStop_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CableStop_cableId_order_key" ON "CableStop"("cableId", "order");
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "sqlite"
|
||||
@@ -21,6 +21,7 @@ model Location {
|
||||
// A location can be the start OR end of many cables
|
||||
startCables Cable[] @relation("StartLocation")
|
||||
endCables Cable[] @relation("EndLocation")
|
||||
cableStops CableStop[]
|
||||
}
|
||||
|
||||
// A single cable run documented in the system
|
||||
@@ -39,6 +40,7 @@ model Cable {
|
||||
endLocation Location @relation("EndLocation", fields: [endLocationId], references: [id])
|
||||
|
||||
cores Core[] // One cable can have many cores/wires
|
||||
intermediateStops CableStop[]
|
||||
}
|
||||
|
||||
// A single wire/core within a cable (e.g., "Blau", "Rot/Weiß")
|
||||
@@ -49,4 +51,15 @@ model Core {
|
||||
|
||||
cableId Int
|
||||
cable Cable @relation(fields: [cableId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model CableStop {
|
||||
id Int @id @default(autoincrement())
|
||||
order Int
|
||||
cable Cable @relation(fields: [cableId], references: [id], onDelete: Cascade)
|
||||
cableId Int
|
||||
location Location @relation(fields: [locationId], references: [id])
|
||||
locationId Int
|
||||
|
||||
@@unique([cableId, order])
|
||||
}
|
||||
Reference in New Issue
Block a user