Events can take a waitlist for sold-out lines. When places free up (cancellation, smaller booking, higher stock limit) the next person is offered them with a claim link and the places are held for a set time; unclaimed offers expire and move on, with optional partial offers. Stock is now counted in one place (utils/stock.js), including held places, and manual registrations and booking edits are now stock-checked. Adds a supervisor waitlist page, My Events waitlists, and the daily summary count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.5 KiB
SQL
64 lines
2.5 KiB
SQL
-- CreateEnum
|
|
CREATE TYPE "WaitlistStatus" AS ENUM ('waiting', 'offered', 'claimed', 'expired', 'removed', 'left');
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "Event" ADD COLUMN "waitlistEnabled" BOOLEAN NOT NULL DEFAULT false,
|
|
ADD COLUMN "waitlistOfferHours" INTEGER NOT NULL DEFAULT 24,
|
|
ADD COLUMN "waitlistPartialOffers" BOOLEAN NOT NULL DEFAULT true;
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "WaitlistEntry" (
|
|
"id" TEXT NOT NULL,
|
|
"eventId" TEXT NOT NULL,
|
|
"eventOptionId" TEXT NOT NULL,
|
|
"variantId" TEXT,
|
|
"userId" TEXT NOT NULL,
|
|
"quantity" INTEGER NOT NULL,
|
|
"position" INTEGER NOT NULL,
|
|
"status" "WaitlistStatus" NOT NULL DEFAULT 'waiting',
|
|
"offeredQuantity" INTEGER,
|
|
"offerTokenHash" TEXT,
|
|
"offeredAt" TIMESTAMP(3),
|
|
"offerExpiresAt" TIMESTAMP(3),
|
|
"claimedAt" TIMESTAMP(3),
|
|
"registrationId" TEXT,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "WaitlistEntry_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "WaitlistEntry_offerTokenHash_key" ON "WaitlistEntry"("offerTokenHash");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "WaitlistEntry_eventId_status_position_idx" ON "WaitlistEntry"("eventId", "status", "position");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "WaitlistEntry_eventOptionId_status_idx" ON "WaitlistEntry"("eventOptionId", "status");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "WaitlistEntry_variantId_idx" ON "WaitlistEntry"("variantId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "WaitlistEntry_userId_idx" ON "WaitlistEntry"("userId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "WaitlistEntry_registrationId_idx" ON "WaitlistEntry"("registrationId");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "WaitlistEntry" ADD CONSTRAINT "WaitlistEntry_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "WaitlistEntry" ADD CONSTRAINT "WaitlistEntry_eventOptionId_fkey" FOREIGN KEY ("eventOptionId") REFERENCES "EventOption"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "WaitlistEntry" ADD CONSTRAINT "WaitlistEntry_variantId_fkey" FOREIGN KEY ("variantId") REFERENCES "OptionVariant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "WaitlistEntry" ADD CONSTRAINT "WaitlistEntry_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "WaitlistEntry" ADD CONSTRAINT "WaitlistEntry_registrationId_fkey" FOREIGN KEY ("registrationId") REFERENCES "Registration"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|