2025-01-14 23:15:37 +01:00
|
|
|
// This is your Prisma schema file,
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
|
|
|
|
generator client {
|
2025-01-17 23:02:39 +01:00
|
|
|
provider = "prisma-client-js"
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
datasource db {
|
2025-01-17 23:02:39 +01:00
|
|
|
provider = "mysql"
|
|
|
|
url = env("DATABASE_URL")
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
enum contentType {
|
2025-01-17 23:02:39 +01:00
|
|
|
voice_alarm
|
|
|
|
voice_explainer
|
|
|
|
voice_acknowledgement
|
|
|
|
voice_ending
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
enum alertType {
|
|
|
|
generic
|
|
|
|
fire
|
|
|
|
fault
|
|
|
|
intrusion
|
|
|
|
clear
|
|
|
|
}
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
enum alertState {
|
2025-02-03 22:23:37 +01:00
|
|
|
incoming // Incoming alerts
|
|
|
|
running // Started calling
|
|
|
|
failed // Failed to get acknowledgement of any alertContacts
|
|
|
|
acknowledged // Some user acknowledged alert
|
2025-01-17 23:02:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
model alerts {
|
2025-02-03 22:23:37 +01:00
|
|
|
id Int @id @unique @default(autoincrement())
|
|
|
|
type alertType
|
2025-01-17 23:02:39 +01:00
|
|
|
state alertState
|
2025-02-03 22:23:37 +01:00
|
|
|
|
|
|
|
description String?
|
|
|
|
date DateTime
|
|
|
|
|
|
|
|
actionplan actionPlan? @relation(fields: [actionplanId], references: [id])
|
|
|
|
actionplanId Int?
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
acknowledged_by alertContacts[]
|
|
|
|
acknowledged_at DateTime?
|
2025-01-14 23:15:37 +01:00
|
|
|
|
2025-02-03 22:23:37 +01:00
|
|
|
@@fulltext([description])
|
|
|
|
}
|
2025-01-14 23:15:37 +01:00
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
model alertContacts {
|
2025-02-03 22:23:37 +01:00
|
|
|
id Int @id @unique @default(autoincrement())
|
2025-01-17 23:02:39 +01:00
|
|
|
name String
|
2025-02-03 22:23:37 +01:00
|
|
|
phone String @unique
|
2025-01-17 23:02:39 +01:00
|
|
|
comment String?
|
|
|
|
prios priorities[]
|
2025-02-03 22:23:37 +01:00
|
|
|
alerts alerts[]
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
@@fulltext([name, phone, comment])
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
model actionPlan {
|
2025-02-03 22:23:37 +01:00
|
|
|
id Int @id @unique @default(autoincrement())
|
|
|
|
name String @unique
|
|
|
|
comment String?
|
2025-02-09 16:08:41 +01:00
|
|
|
alerthook String @unique @default(ulid())
|
2025-02-03 22:23:37 +01:00
|
|
|
prio priorities[]
|
|
|
|
content content[] // aka. all voice files
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
alerts alerts[]
|
2025-02-03 22:23:37 +01:00
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
@@fulltext([name, comment])
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
model priorities {
|
2025-02-03 22:23:37 +01:00
|
|
|
id Int @id @unique @default(autoincrement())
|
|
|
|
Contact alertContacts @relation(fields: [contactId], references: [id])
|
|
|
|
contactId Int
|
|
|
|
priority Int
|
|
|
|
actionplan actionPlan @relation(fields: [actionplanId], references: [id])
|
|
|
|
actionplanId Int
|
2025-01-17 23:02:39 +01:00
|
|
|
|
|
|
|
@@unique([priority, actionplanId])
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
2025-01-17 23:02:39 +01:00
|
|
|
model content {
|
2025-02-09 19:28:30 +01:00
|
|
|
//id Int @id @unique @default(autoincrement())
|
|
|
|
s3_key String @id @unique
|
2025-02-09 16:08:41 +01:00
|
|
|
name String @unique
|
2025-02-09 19:28:30 +01:00
|
|
|
type contentType
|
2025-02-03 22:23:37 +01:00
|
|
|
actionplan actionPlan[]
|
|
|
|
|
2025-02-09 19:28:30 +01:00
|
|
|
@@fulltext([name])
|
2025-01-14 23:15:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://spacecdn.de/file/bma_stoe_v1.mp3
|
|
|
|
// https://spacecdn.de/file/quittiert_v1.mp3
|
|
|
|
// https://spacecdn.de/file/angenehmen_tag_v1.mp3
|
|
|
|
// https://spacecdn.de/file/erklaerung_v1.mp3
|