Files
cable-manager/prisma/schema.prisma
2026-06-13 17:02:58 +02:00

65 lines
2.0 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Get a free hosted Postgres database in seconds: `npx create-db`
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "sqlite"
}
// A physical location in the building (e.g., "Serverraum", "Wohnzimmer")
model Location {
id Int @id @default(autoincrement())
name String
description String? // Optional Markdown text
// 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
model Cable {
id Int @id @default(autoincrement())
identifier String // e.g. "Kabel 01", "LAN-01"
description String? // Short plain-text summary
notes String? // Long-form Markdown notes
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
startLocationId Int
endLocationId Int
startLocation Location @relation("StartLocation", fields: [startLocationId], references: [id])
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ß")
model Core {
id Int @id @default(autoincrement())
color String // Color designation, e.g. "Blau", "Braun/Weiß"
notes String? // Optional Markdown notes
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])
}