Merge family absence flows while preserving security hardening
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
-- Family invitation delivery status; applied before the restricted runtime starts.
|
||||
ALTER TABLE "invitations"
|
||||
ADD COLUMN "userId" TEXT,
|
||||
ADD COLUMN "sentAt" TIMESTAMP(3),
|
||||
ADD COLUMN "lastAttemptAt" TIMESTAMP(3),
|
||||
ADD COLUMN "leaseUntil" TIMESTAMP(3),
|
||||
ADD COLUMN "attempts" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN "failed" BOOLEAN NOT NULL DEFAULT false;
|
||||
CREATE UNIQUE INDEX "invitations_userId_key" ON "invitations"("userId");
|
||||
ALTER TABLE "invitations" ADD CONSTRAINT "invitations_userId_fkey"
|
||||
FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE "invitations" ADD CONSTRAINT "invitations_userId_tenant_fkey"
|
||||
FOREIGN KEY ("userId", "kitaId") REFERENCES "users"("id", "kitaId") ON DELETE CASCADE ON UPDATE NO ACTION;
|
||||
@@ -268,6 +268,7 @@ model User {
|
||||
|
||||
mitbringselItems MitbringselItem[]
|
||||
invitationsCreated Invitation[] @relation("InvitationCreator")
|
||||
familyInvitation Invitation? @relation("InvitationRecipient")
|
||||
auditLogsAuthored AuditLog[] @relation("AuditLogActor")
|
||||
staffProfile StaffProfile?
|
||||
staffNotifications StaffNotification[]
|
||||
@@ -749,10 +750,19 @@ model Invitation {
|
||||
email String
|
||||
role UserRole @default(ELTERN)
|
||||
|
||||
// Nullable for older, unlinked invitations. Family invitations belong to a user.
|
||||
userId String? @unique
|
||||
user User? @relation("InvitationRecipient", fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
token String @unique
|
||||
status InvitationStatus @default(PENDING)
|
||||
expiresAt DateTime
|
||||
acceptedAt DateTime?
|
||||
sentAt DateTime?
|
||||
lastAttemptAt DateTime?
|
||||
leaseUntil DateTime?
|
||||
attempts Int @default(0)
|
||||
failed Boolean @default(false)
|
||||
|
||||
invitedById String?
|
||||
invitedBy User? @relation("InvitationCreator", fields: [invitedById], references: [id], onDelete: SetNull)
|
||||
|
||||
Reference in New Issue
Block a user