Merge family absence flows while preserving security hardening
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-- Historical upgrade helper, retained for compatibility tests only.
|
||||
-- Production uses prisma/migrations/20261010000000_family_invitation_flows.
|
||||
-- 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$;
|
||||
Reference in New Issue
Block a user