continued the kita-planer
This commit is contained in:
+179
-23
@@ -32,6 +32,7 @@ enum UserRole {
|
||||
SUPERADMIN
|
||||
ADMIN
|
||||
KOORDINATOR
|
||||
ERZIEHER
|
||||
ELTERN
|
||||
}
|
||||
|
||||
@@ -73,6 +74,18 @@ enum NotdienstAlertStatus {
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
enum DutyAssignmentStatus {
|
||||
PLANNED
|
||||
DONE
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
enum AbsenceReason {
|
||||
ILLNESS
|
||||
VACATION
|
||||
OTHER
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// TENANT
|
||||
// =====================================================================
|
||||
@@ -96,10 +109,15 @@ model Kita {
|
||||
|
||||
// Relations (Cascade auf alle Tenant-Daten)
|
||||
users User[]
|
||||
families Family[]
|
||||
children Child[]
|
||||
educators Educator[]
|
||||
parentDuties ParentDuty[]
|
||||
parentDutyAssignments ParentDutyAssignment[]
|
||||
dutyTypes DutyType[]
|
||||
dutyAssignments DutyAssignment[]
|
||||
absences Absence[]
|
||||
announcements Announcement[]
|
||||
invitations Invitation[]
|
||||
termine Termin[]
|
||||
mitbringselItems MitbringselItem[]
|
||||
@@ -107,11 +125,33 @@ model Kita {
|
||||
notdienstAvailabilities NotdienstAvailability[]
|
||||
notdienstAssignments NotdienstAssignment[]
|
||||
notdienstAlerts NotdienstAlert[]
|
||||
childParents ChildParent[]
|
||||
|
||||
@@map("kitas")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// FAMILIES / HAUSHALTE
|
||||
// =====================================================================
|
||||
|
||||
model Family {
|
||||
id String @id @default(cuid())
|
||||
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
name String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
users User[]
|
||||
children Child[]
|
||||
dutyAssignments DutyAssignment[]
|
||||
|
||||
@@index([kitaId])
|
||||
@@map("families")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// USERS
|
||||
// =====================================================================
|
||||
@@ -124,6 +164,11 @@ model User {
|
||||
kitaId String?
|
||||
kita Kita? @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
/// Optional, weil Admins/Superadmins keinem Haushalt angehören müssen.
|
||||
/// Eltern-User werden beim Löschen ihrer Familie kaskadiert entfernt.
|
||||
familyId String?
|
||||
family Family? @relation(fields: [familyId], references: [id], onDelete: Cascade)
|
||||
|
||||
email String @unique
|
||||
passwordHash String
|
||||
|
||||
@@ -157,13 +202,14 @@ model User {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// Relations
|
||||
childLinks ChildParent[]
|
||||
dutyAssignments ParentDutyAssignment[]
|
||||
|
||||
notdienstAvailabilities NotdienstAvailability[]
|
||||
notdienstAlertsAssigned NotdienstAlert[] @relation("NotdienstAlertParent")
|
||||
notdienstAlertsTriggered NotdienstAlert[] @relation("NotdienstAlertTrigger")
|
||||
notdienstPlansCreated NotdienstPlan[] @relation("NotdienstPlanCreator")
|
||||
announcementsAuthored Announcement[] @relation("AnnouncementAuthor")
|
||||
announcementReads AnnouncementRead[]
|
||||
|
||||
termineCreated Termin[] @relation("TerminCreator")
|
||||
termineApproved Termin[] @relation("TerminApprover")
|
||||
@@ -172,6 +218,7 @@ model User {
|
||||
invitationsCreated Invitation[] @relation("InvitationCreator")
|
||||
|
||||
@@index([kitaId])
|
||||
@@index([familyId])
|
||||
@@index([kitaId, role])
|
||||
@@map("users")
|
||||
}
|
||||
@@ -185,6 +232,9 @@ model Child {
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
familyId String
|
||||
family Family @relation(fields: [familyId], references: [id], onDelete: Cascade)
|
||||
|
||||
firstName String
|
||||
lastName String
|
||||
dateOfBirth DateTime?
|
||||
@@ -195,34 +245,15 @@ model Child {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
parentLinks ChildParent[]
|
||||
notdienstAvailabilities NotdienstAvailability[]
|
||||
notdienstAssignments NotdienstAssignment[]
|
||||
absences Absence[]
|
||||
|
||||
@@index([kitaId])
|
||||
@@index([familyId])
|
||||
@@map("children")
|
||||
}
|
||||
|
||||
/// Verknüpfung Kind ↔ Elternteil (m:n).
|
||||
/// Kaskadiert über beide Seiten, damit das Löschen eines Users
|
||||
/// oder Kindes keine Datenleichen hinterlässt.
|
||||
model ChildParent {
|
||||
id String @id @default(cuid())
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
childId String
|
||||
child Child @relation(fields: [childId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@unique([childId, userId])
|
||||
@@index([kitaId])
|
||||
@@index([userId])
|
||||
@@map("child_parents")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// EDUCATORS (ErzieherInnen — reine Stammdaten, keine Logins, Modul 4)
|
||||
// =====================================================================
|
||||
@@ -285,6 +316,131 @@ model ParentDutyAssignment {
|
||||
@@map("parent_duty_assignments")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// DUTY PLANNING (Top-Down-Dienstplan fuer Haushalte)
|
||||
// =====================================================================
|
||||
|
||||
model DutyType {
|
||||
id String @id @default(cuid())
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
name String
|
||||
description String?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
assignments DutyAssignment[]
|
||||
|
||||
@@unique([kitaId, name])
|
||||
@@index([kitaId])
|
||||
@@map("duty_types")
|
||||
}
|
||||
|
||||
model DutyAssignment {
|
||||
id String @id @default(cuid())
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
familyId String
|
||||
family Family @relation(fields: [familyId], references: [id], onDelete: Cascade)
|
||||
|
||||
dutyTypeId String
|
||||
dutyType DutyType @relation(fields: [dutyTypeId], references: [id], onDelete: Cascade)
|
||||
|
||||
startDate DateTime @db.Date
|
||||
endDate DateTime @db.Date
|
||||
status DutyAssignmentStatus @default(PLANNED)
|
||||
|
||||
reminderSentAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([kitaId, dutyTypeId, startDate])
|
||||
@@index([kitaId, startDate])
|
||||
@@index([familyId, startDate])
|
||||
@@map("duty_assignments")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// ABSENCES (Abwesenheits- und Krankmeldungen)
|
||||
// =====================================================================
|
||||
|
||||
model Absence {
|
||||
id String @id @default(cuid())
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
childId String
|
||||
child Child @relation(fields: [childId], references: [id], onDelete: Cascade)
|
||||
|
||||
startDate DateTime @db.Date
|
||||
endDate DateTime @db.Date
|
||||
reason AbsenceReason
|
||||
note String?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([kitaId, startDate, endDate])
|
||||
@@index([childId, startDate])
|
||||
@@map("absences")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// ANNOUNCEMENTS (Digitales Schwarzes Brett)
|
||||
// =====================================================================
|
||||
|
||||
model Announcement {
|
||||
id String @id @default(cuid())
|
||||
kitaId String
|
||||
kita Kita @relation(fields: [kitaId], references: [id], onDelete: Cascade)
|
||||
|
||||
title String
|
||||
content String
|
||||
|
||||
authorId String
|
||||
author User @relation("AnnouncementAuthor", fields: [authorId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
attachments Attachment[]
|
||||
reads AnnouncementRead[]
|
||||
|
||||
@@index([kitaId, createdAt])
|
||||
@@index([authorId])
|
||||
@@map("announcements")
|
||||
}
|
||||
|
||||
model Attachment {
|
||||
id String @id @default(cuid())
|
||||
announcementId String
|
||||
announcement Announcement @relation(fields: [announcementId], references: [id], onDelete: Cascade)
|
||||
|
||||
fileName String
|
||||
fileUrl String
|
||||
fileType String
|
||||
|
||||
@@index([announcementId])
|
||||
@@map("attachments")
|
||||
}
|
||||
|
||||
model AnnouncementRead {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
announcementId String
|
||||
announcement Announcement @relation(fields: [announcementId], references: [id], onDelete: Cascade)
|
||||
|
||||
readAt DateTime @default(now())
|
||||
|
||||
@@unique([userId, announcementId])
|
||||
@@index([announcementId])
|
||||
@@map("announcement_reads")
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// INVITATIONS (Invite-Only Onboarding, Modul 3)
|
||||
// =====================================================================
|
||||
|
||||
Reference in New Issue
Block a user