logic for eventGuests

This commit is contained in:
2025-06-28 15:00:08 -04:00
parent b2f3be0f0c
commit dee9066c91
8 changed files with 174 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
-- CreateTable
CREATE TABLE "EventGuest" (
"id" TEXT NOT NULL,
"eventId" TEXT NOT NULL,
"guestBookEntryId" TEXT NOT NULL,
"rsvp" "RsvpStatus" NOT NULL DEFAULT 'PENDING',
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "EventGuest_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "EventGuest_eventId_guestBookEntryId_key" ON "EventGuest"("eventId", "guestBookEntryId");
-- AddForeignKey
ALTER TABLE "EventGuest" ADD CONSTRAINT "EventGuest_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "EventGuest" ADD CONSTRAINT "EventGuest_guestBookEntryId_fkey" FOREIGN KEY ("guestBookEntryId") REFERENCES "GuestBookEntry"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -32,6 +32,7 @@ model Event {
creator User @relation("EventCreator", fields: [creatorId], references: [id])
creatorId String
guests Guest[]
eventGuests EventGuest[]
createdAt DateTime @default(now())
}
@@ -70,7 +71,19 @@ model GuestBookEntry {
address String?
notes String?
side String // e.g., "Brian", "Janice", etc.
eventGuests EventGuest[]
createdAt DateTime @default(now())
}
model EventGuest {
id String @id @default(cuid())
event Event @relation(fields: [eventId], references: [id])
eventId String
guestBookEntry GuestBookEntry @relation(fields: [guestBookEntryId], references: [id])
guestBookEntryId String
rsvp RsvpStatus @default(PENDING)
createdAt DateTime @default(now())
@@unique([eventId, guestBookEntryId])
}