Improve family invitations and absence management flows

This commit is contained in:
t.indorf
2026-10-09 22:59:36 +02:00
parent 4702bf5abb
commit 8915fe7df6
29 changed files with 2803 additions and 617 deletions
+30
View File
@@ -0,0 +1,30 @@
-- Additive upgrade before Prisma db push; safe to run repeatedly.
-- On a fresh database Prisma creates the entire schema afterwards.
DO $upgrade$
BEGIN
IF to_regclass('invitations') IS NULL THEN
RETURN;
END IF;
ALTER TABLE "invitations"
ADD COLUMN IF NOT EXISTS "userId" TEXT,
ADD COLUMN IF NOT EXISTS "sentAt" TIMESTAMP(3),
ADD COLUMN IF NOT EXISTS "lastAttemptAt" TIMESTAMP(3),
ADD COLUMN IF NOT EXISTS "leaseUntil" TIMESTAMP(3),
ADD COLUMN IF NOT EXISTS "attempts" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS "failed" BOOLEAN NOT NULL DEFAULT false;
CREATE UNIQUE INDEX IF NOT EXISTS "invitations_userId_key" ON "invitations"("userId");
IF NOT EXISTS (
SELECT 1 FROM pg_constraint
WHERE conname = 'invitations_userId_fkey'
AND conrelid = 'invitations'::regclass
) THEN
ALTER TABLE "invitations"
ADD CONSTRAINT "invitations_userId_fkey"
FOREIGN KEY ("userId") REFERENCES "users"("id")
ON DELETE CASCADE ON UPDATE CASCADE;
END IF;
END
$upgrade$;