-- Church App 1.0.0: email and WhatsApp (docs/APP-1.0-PLAN.md ยง8): members' news consent from Accounts, -- what each member chose the App sends them, what each outbox message went by, and the counts per day. -- CreateEnum CREATE TYPE "NotifyChoice" AS ENUM ('off', 'email', 'whatsapp', 'both'); -- AlterTable ALTER TABLE "Member" ADD COLUMN "newsEmail" BOOLEAN NOT NULL DEFAULT false, ADD COLUMN "newsWhatsApp" BOOLEAN NOT NULL DEFAULT false; -- AlterTable ALTER TABLE "OutboxMessage" ADD COLUMN "sentVia" TEXT; -- CreateTable CREATE TABLE "NotificationSettings" ( "memberId" TEXT NOT NULL, "requestUpdates" "NotifyChoice" NOT NULL DEFAULT 'email', "announcements" "NotifyChoice" NOT NULL DEFAULT 'off', "devotional" "NotifyChoice" NOT NULL DEFAULT 'off', "devotionalTime" TEXT NOT NULL DEFAULT '06:00', "devotionalOfferedAt" TIMESTAMP(3), "lastDevotionalDate" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL, CONSTRAINT "NotificationSettings_pkey" PRIMARY KEY ("memberId") ); -- CreateTable CREATE TABLE "MessageCount" ( "key" TEXT NOT NULL, "day" TEXT NOT NULL, "channel" TEXT NOT NULL, "count" INTEGER NOT NULL DEFAULT 0, CONSTRAINT "MessageCount_pkey" PRIMARY KEY ("key") ); -- CreateIndex CREATE INDEX "NotificationSettings_devotional_idx" ON "NotificationSettings"("devotional"); -- CreateIndex CREATE INDEX "MessageCount_day_idx" ON "MessageCount"("day"); -- AddForeignKey ALTER TABLE "NotificationSettings" ADD CONSTRAINT "NotificationSettings_memberId_fkey" FOREIGN KEY ("memberId") REFERENCES "Member"("id") ON DELETE CASCADE ON UPDATE CASCADE;