// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" output = "../generated/prisma" } datasource db { provider = "sqlite" url = env("DATABASE_URL") } model MeasurementPoint { id String @id @default(cuid()) sensorId String @unique // e.g., "head-1", "back-2" label String // e.g., "Head Left", "Upper Back Center" zone String // e.g., "head", "back", "shoulders" x Int // X coordinate on bed layout y Int // Y coordinate on bed layout pin Int // Hardware pin number // Threshold configuration warningThreshold Int // Pressure value that triggers warning alarmThreshold Int // Pressure value that triggers alarm warningDelayMs Int // Delay before warning escalates to alarm // Timestamps createdAt DateTime @default(now()) updatedAt DateTime @updatedAt // Relations data MeasurementPointData[] alerts Alert[] } model MeasurementPointData { id String @id @default(cuid()) measurementPointId String // Sensor reading data value Int // Analog sensor value (0-4095) // Timestamps timestamp DateTime @default(now()) time String // Formatted time string // Relations measurementPoint MeasurementPoint @relation(fields: [measurementPointId], references: [id], onDelete: Cascade) @@index([measurementPointId, timestamp]) } enum AlertType { WARNING ALARM } model Alert { id String @id @default(cuid()) measurementPointId String // Alert details type AlertType value Int // Sensor value that triggered alert threshold Int // Threshold that was exceeded // Alert state acknowledged Boolean @default(false) silenced Boolean @default(false) // Timing startTime DateTime @default(now()) endTime DateTime? // Relations measurementPoint MeasurementPoint @relation(fields: [measurementPointId], references: [id], onDelete: Cascade) @@index([measurementPointId, startTime]) @@index([type, acknowledged]) }