Files

14 lines
773 B
SQL

-- 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;