From 8383080395c82d33a0af889e689fa4466d8e1752 Mon Sep 17 00:00:00 2001 From: Spacelord Date: Mon, 3 Feb 2025 22:23:37 +0100 Subject: [PATCH] schema updates --- README.MD | 31 ++++++++++++++++++ docs/schema.dbml | 14 ++++---- prisma/schema.prisma | 76 +++++++++++++++++++++++--------------------- 3 files changed, 78 insertions(+), 43 deletions(-) diff --git a/README.MD b/README.MD index b89e6cc..f9bfa19 100644 --- a/README.MD +++ b/README.MD @@ -16,3 +16,34 @@ Funktionen: - Erklärung MP3 - Quittierung MP3 - Verabschiedung MP3 + + +## API Endpoint planning + +alertContacts (CRUD Fully implemented) +alerts -> Only get + + +actionPlan (CRUD) +- select all prios + +priorities (CRUD) +- select actionPlan +- Only allow changes to priority + +content (CRUD) +- Howto handle upload? + + + +POST /alert/[:alert_hook] +-> Check actionplan if hook exists and select current prios -> Write call request to XYXYX + + + + +1. create one or more alertContacts +2. create 4x content (all phases) +3. create actionplan with contents +4. create one or more priorities + diff --git a/docs/schema.dbml b/docs/schema.dbml index 128b073..721abfa 100644 --- a/docs/schema.dbml +++ b/docs/schema.dbml @@ -2,7 +2,7 @@ //// THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) //// ------------------------------------------------------ -Project "AssetFlow" { +Project "ATAS" { database_type: '' Note: '' } @@ -10,11 +10,11 @@ Project "AssetFlow" { Table alerts { id Int [pk, increment] type alertType [not null] - message String + state alertState [not null] + description String + date DateTime [not null] actionplan actionPlan actionplanId Int - date DateTime [not null] - state alertState [not null] acknowledged_by alertContacts [not null] acknowledged_at DateTime } @@ -30,9 +30,9 @@ Table alertContacts { Table actionPlan { id Int [pk, increment] - name String [not null] + name String [unique, not null] comment String - alert_hook String [unique, not null] + alerthook String [unique, not null] prio priorities [not null] content content [not null] alerts alerts [not null] @@ -85,7 +85,7 @@ Enum alertType { } Enum alertState { - incomming + incoming running failed acknowledged diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ed7dfa2..d155512 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -26,7 +26,7 @@ generator dbml { provider = "prisma-dbml-generator" output = "../docs" outputName = "schema.dbml" - projectName = "AssetFlow" + projectName = "ATAS" } @@ -46,70 +46,74 @@ enum alertType { } enum alertState { - incomming // Incomming alerts - running // Started calling - failed // Failed to get acknowledgement of any alertContacts - acknowledged // Some user acknowledged alert + 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 - message String? - actionplan actionPlan? @relation(fields: [actionplanId], references: [id]) - actionplanId Int? - date DateTime + 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([message]) + + @@fulltext([description]) } - model alertContacts { - id Int @id @unique @default(autoincrement()) + id Int @id @unique @default(autoincrement()) name String - phone String @unique + phone String @unique comment String? prios priorities[] - alerts alerts[] + alerts alerts[] + @@fulltext([name, phone, comment]) } model actionPlan { - id Int @id @unique @default(autoincrement()) - name String - comment String? - alert_hook String @unique - prio priorities[] - content content[] // aka. all voice files + 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 + 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[] + 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