-- AlterTable
ALTER TABLE "GuestInvite" ADD COLUMN     "phone" TEXT,
ADD COLUMN     "smsSent" BOOLEAN NOT NULL DEFAULT false,
ALTER COLUMN "email" DROP NOT NULL;

-- AlterTable
ALTER TABLE "Rsvp" ADD COLUMN     "guestPhone" TEXT,
ALTER COLUMN "guestEmail" DROP NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "GuestInvite_eventId_phone_key" ON "GuestInvite"("eventId", "phone");

-- CreateIndex
CREATE UNIQUE INDEX "Rsvp_eventId_guestPhone_key" ON "Rsvp"("eventId", "guestPhone");

-- CheckConstraint: not expressible in Prisma's schema language, so added by
-- hand. Every existing row already has a non-null guestEmail/email (the
-- prior schema required it), so no backfill is needed before adding these.
ALTER TABLE "Rsvp" ADD CONSTRAINT "rsvp_guest_contact_check"
  CHECK ("guestEmail" IS NOT NULL OR "guestPhone" IS NOT NULL);

ALTER TABLE "GuestInvite" ADD CONSTRAINT "guestinvite_contact_check"
  CHECK ("email" IS NOT NULL OR "phone" IS NOT NULL);

