-- CreateTable
CREATE TABLE IF NOT EXISTS "EmailAutomation" (
    "id" TEXT NOT NULL,
    "ownerId" TEXT NOT NULL,
    "inviteEnabled" BOOLEAN NOT NULL DEFAULT false,
    "checkInEnabled" BOOLEAN NOT NULL DEFAULT false,
    "reminderEnabled" BOOLEAN NOT NULL DEFAULT false,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    CONSTRAINT "EmailAutomation_pkey" PRIMARY KEY ("id")
);

CREATE UNIQUE INDEX IF NOT EXISTS "EmailAutomation_ownerId_key" ON "EmailAutomation"("ownerId");
ALTER TABLE "EmailAutomation" ADD CONSTRAINT "EmailAutomation_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "Owner"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- Visitor dedupe field for reminder cron
ALTER TABLE "Visitor" ADD COLUMN IF NOT EXISTS "reminderSentAt" TIMESTAMP(3);
