feat(backend): Benachrichtigungssystem (Modul 26)

NotificationsModule: Notification-Modell mit Prioritaeten INFO/
HINWEIS/WARNUNG/KRITISCH, GET /notifications (eigene + Broadcast),
POST /notifications/:id/read. record() als interne API fuer
kuenftige Automatisierungsregeln (Modul 30) vorgesehen.
This commit is contained in:
Nick Szaunig committed 2026-08-22 22:43:38 +02:00
1 parent 9b078022ff
commit a57cde1f9a
9 files changed
+299 -1

No files matched your search

@@ -0,0 +1,25 @@
-- CreateEnum
CREATE TYPE "NotificationPriority" AS ENUM ('INFO', 'HINWEIS', 'WARNUNG', 'KRITISCH');
-- CreateTable
CREATE TABLE "Notification" (
"id" TEXT NOT NULL,
"userId" TEXT,
"priority" "NotificationPriority" NOT NULL,
"message" TEXT NOT NULL,
"relatedType" TEXT,
"relatedId" TEXT,
"read" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Notification_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "Notification_userId_read_idx" ON "Notification"("userId", "read");
-- CreateIndex
CREATE INDEX "Notification_priority_idx" ON "Notification"("priority");
-- AddForeignKey
ALTER TABLE "Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+27
View File
@@ -50,6 +50,7 @@ model User {
colonyMoves ColonyApiaryHistory[]
auditLogs AuditLog[]
bottlingBatches BottlingBatch[]
notifications Notification[]
@@index([role])
}
@@ -698,3 +699,29 @@ model Equipment {
@@index([condition])
}
// ---------------------------------------------------------------------------
// Benachrichtigungssystem (Abschnitt 24) – v1.x Modul 26
// ---------------------------------------------------------------------------
enum NotificationPriority {
INFO
HINWEIS
WARNUNG
KRITISCH
}
model Notification {
id String @id @default(cuid())
userId String?
user User? @relation(fields: [userId], references: [id])
priority NotificationPriority
message String
relatedType String?
relatedId String?
read Boolean @default(false)
createdAt DateTime @default(now())
@@index([userId, read])
@@index([priority])
}