atas/prisma/schema.prisma

104 lines
2.2 KiB
Plaintext

// 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 {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
enum contentType {
voice_alarm
voice_explainer
voice_acknowledgement
voice_ending
}
enum alertType {
generic
fire
fault
intrusion
clear
}
enum alertState {
incoming // Incoming alerts
running // Started calling
failed // Failed to get acknowledgement of any alertContacts
acknowledged // Some user acknowledged alert
}
model alerts {
id Int @id @unique @default(autoincrement())
type alertType
state alertState
description String?
date DateTime
actionplan actionPlan? @relation(fields: [actionplanId], references: [id])
actionplanId Int?
acknowledged_by alertContacts[]
acknowledged_at DateTime?
@@fulltext([description])
}
model alertContacts {
id Int @id @unique @default(autoincrement())
name String
phone String @unique
comment String?
prios priorities[]
alerts alerts[]
@@fulltext([name, phone, comment])
}
model actionPlan {
id Int @id @unique @default(autoincrement())
name String @unique
comment String?
alerthook String @unique
prio priorities[]
content content[] // aka. all voice files
alerts alerts[]
@@fulltext([name, comment])
}
model priorities {
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
@@unique([priority, actionplanId])
}
model content {
id Int @id @unique @default(autoincrement())
type contentType
name String
filename String
actionplan actionPlan[]
@@fulltext([name, filename])
}
// 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