chris 2c78112a4f Initial commit: E-Invite, a self-hosted Evite-lite
Docker-ready Next.js + Prisma/Postgres e-invitation app: themed invite
pages, RSVP, comments, share links, email + SMS invites with
reply-to-RSVP-by-text, co-hosts, photo dropbox, and browser push
notifications.
2026-07-11 10:11:12 -04:00

22 lines
1016 B
SQL

-- DropIndex
DROP INDEX "GuestInvite_eventId_idx";
-- AlterTable
ALTER TABLE "Event" ADD COLUMN "timezone" TEXT NOT NULL DEFAULT 'UTC';
-- AlterTable: nullable first so existing rows can be backfilled, then
-- tightened to NOT NULL - a plain NOT NULL ADD COLUMN would fail against
-- any pre-existing EventCollaborator rows.
ALTER TABLE "EventCollaborator" ADD COLUMN "expiresAt" TIMESTAMP(3);
UPDATE "EventCollaborator" SET "expiresAt" = "createdAt" + INTERVAL '7 days' WHERE "expiresAt" IS NULL;
ALTER TABLE "EventCollaborator" ALTER COLUMN "expiresAt" SET NOT NULL;
-- Deduplicate before adding the unique constraint below, keeping the most
-- recent invite per (eventId, email) - defensive in case any duplicates
-- accumulated before this constraint existed.
DELETE FROM "GuestInvite" a USING "GuestInvite" b
WHERE a."eventId" = b."eventId" AND a.email = b.email AND a."sentAt" < b."sentAt";
-- CreateIndex
CREATE UNIQUE INDEX "GuestInvite_eventId_email_key" ON "GuestInvite"("eventId", "email");