Add superadmin audit and Kita management

This commit is contained in:
t.indorf
2026-05-16 12:02:59 +02:00
parent 0b80c62beb
commit 380c67963b
10 changed files with 2007 additions and 39 deletions
+36
View File
@@ -68,6 +68,11 @@ enum EventParticipationStatus {
NOT_ATTENDING
}
enum AuditTargetType {
KITA
USER
}
enum NotdienstPlanStatus {
DRAFT
PUBLISHED
@@ -222,6 +227,7 @@ model User {
mitbringselItems MitbringselItem[]
invitationsCreated Invitation[] @relation("InvitationCreator")
auditLogsAuthored AuditLog[] @relation("AuditLogActor")
@@index([kitaId])
@@index([familyId])
@@ -687,6 +693,36 @@ model NotdienstAlert {
@@map("notdienst_alerts")
}
// =====================================================================
// AUDIT LOGS (Systemweite Superadmin-Aktionen)
// =====================================================================
/// Persistente Spur fuer Superadmin-Support-Aktionen.
/// Zielobjekte werden bewusst nur als Snapshot gespeichert, damit Logs auch
/// nach einer Kita- oder Benutzerloeschung erhalten bleiben.
model AuditLog {
id String @id @default(cuid())
actorUserId String?
actorUser User? @relation("AuditLogActor", fields: [actorUserId], references: [id], onDelete: SetNull)
actorEmail String
action String
targetType AuditTargetType
targetId String
targetLabel String
targetKitaId String?
metadata Json?
createdAt DateTime @default(now())
@@index([actorUserId])
@@index([targetType, targetId])
@@index([targetKitaId])
@@index([createdAt])
@@map("audit_logs")
}
// =====================================================================
// AUTH-HILFSTABELLE
// =====================================================================