-- Create table for production performance schedule
CREATE TABLE "Performance" (
  "id" TEXT NOT NULL,
  "productionId" TEXT NOT NULL,
  "title" TEXT,
  "start" TIMESTAMP(3) NOT NULL,
  "end" TIMESTAMP(3) NOT NULL,
  "note" TEXT,
  "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "updatedAt" TIMESTAMP(3) NOT NULL,
  CONSTRAINT "Performance_pkey" PRIMARY KEY ("id")
);

CREATE INDEX "Performance_productionId_start_idx" ON "Performance" ("productionId", "start");

ALTER TABLE "Performance"
  ADD CONSTRAINT "Performance_productionId_fkey"
  FOREIGN KEY ("productionId") REFERENCES "Production"("id")
  ON DELETE CASCADE ON UPDATE CASCADE;
