Files
kita-planer/deploy/sql/personalbereich-email.sql

40 lines
1.5 KiB
PL/PgSQL

-- HISTORISCHER UPGRADEPFAD: aktuelle Releases verwenden prisma/migrations und deploy/README.md.
-- Nicht zusätzlich zu versionierten Migrationen oder auf bereits aktualisierten Datenbanken ausführen.
-- Nur E-Mail-Erweiterung für einen bereits mit 043fed2 eingeführten Personalbereich.
-- Beschreibt ausschließlich den damaligen Ausgangsstand vor Einführung der Migrationshistorie.
BEGIN;
-- AlterTable
ALTER TABLE "users" ADD COLUMN "staffDecisionEmails" BOOLEAN NOT NULL DEFAULT true;
-- CreateTable
CREATE TABLE "staff_emails" (
"id" TEXT NOT NULL,
"profileId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"toAdmins" BOOLEAN NOT NULL DEFAULT false,
"subject" TEXT NOT NULL,
"message" TEXT NOT NULL,
"path" TEXT NOT NULL,
"inviteToken" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"sentAt" TIMESTAMP(3),
"skippedAt" TIMESTAMP(3),
"leaseUntil" TIMESTAMP(3),
"attempts" INTEGER NOT NULL DEFAULT 0,
"failed" BOOLEAN NOT NULL DEFAULT false,
CONSTRAINT "staff_emails_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "staff_emails_profileId_sentAt_skippedAt_idx" ON "staff_emails"("profileId", "sentAt", "skippedAt");
-- AddForeignKey
ALTER TABLE "staff_emails" ADD CONSTRAINT "staff_emails_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "staff_profiles"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "staff_emails" ADD CONSTRAINT "staff_emails_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;