-- CreateEnum
CREATE TYPE "ProgressReportMeetingStatus" AS ENUM ('DRAFT', 'SENT');

-- CreateTable
CREATE TABLE "progress_report_meetings" (
    "id" SERIAL NOT NULL,
    "progress_report_id" INTEGER NOT NULL,
    "title" VARCHAR(100) NOT NULL,
    "description" JSONB,
    "meeting_date" DATE NOT NULL,
    "start_time" TIME NOT NULL,
    "end_time" TIME NOT NULL,
    "location" VARCHAR(255) NOT NULL,
    "document_reference" VARCHAR(500) NOT NULL,
    "status" "ProgressReportMeetingStatus" NOT NULL DEFAULT 'DRAFT',
    "user_id" INTEGER NOT NULL,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL,
    "deleted_at" TIMESTAMP(3),

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

-- CreateIndex
CREATE INDEX "progress_report_meetings_progress_report_id_idx" ON "progress_report_meetings"("progress_report_id");

-- CreateIndex
CREATE INDEX "progress_report_meetings_status_idx" ON "progress_report_meetings"("status");

-- CreateIndex
CREATE INDEX "progress_report_meetings_meeting_date_idx" ON "progress_report_meetings"("meeting_date");

-- CreateIndex
CREATE INDEX "progress_report_meetings_start_time_idx" ON "progress_report_meetings"("start_time");

-- CreateIndex
CREATE INDEX "progress_report_meetings_end_time_idx" ON "progress_report_meetings"("end_time");

-- CreateIndex
CREATE INDEX "progress_report_meetings_location_idx" ON "progress_report_meetings"("location");

-- CreateIndex
CREATE INDEX "progress_report_meetings_document_reference_idx" ON "progress_report_meetings"("document_reference");

-- CreateIndex
CREATE INDEX "progress_report_meetings_user_id_idx" ON "progress_report_meetings"("user_id");

-- CreateIndex
CREATE INDEX "progress_report_meetings_deleted_at_idx" ON "progress_report_meetings"("deleted_at");

-- AddForeignKey
ALTER TABLE "progress_report_meetings" ADD CONSTRAINT "progress_report_meetings_progress_report_id_fkey" FOREIGN KEY ("progress_report_id") REFERENCES "progress_reports"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "progress_report_meetings" ADD CONSTRAINT "progress_report_meetings_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
