-- CreateTable
CREATE TABLE "MaintenanceChecklist" (
    "id" TEXT NOT NULL,
    "taskId" TEXT NOT NULL,
    "items" JSONB NOT NULL,
    "completedAt" TIMESTAMP(3),
    "signedById" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "MaintenanceChecklist_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "MaintenanceChecklist_taskId_key" ON "MaintenanceChecklist"("taskId");

-- CreateIndex
CREATE INDEX "MaintenanceChecklist_taskId_idx" ON "MaintenanceChecklist"("taskId");

-- CreateIndex
CREATE INDEX "MaintenanceChecklist_signedById_idx" ON "MaintenanceChecklist"("signedById");

-- AddForeignKey
ALTER TABLE "MaintenanceChecklist" ADD CONSTRAINT "MaintenanceChecklist_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "MaintenanceTask"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MaintenanceChecklist" ADD CONSTRAINT "MaintenanceChecklist_signedById_fkey" FOREIGN KEY ("signedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
