-- CreateEnum
CREATE TYPE "ProgressReportSemester" AS ENUM ('S1', 'S2');

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

-- CreateTable
CREATE TABLE "progress_reports" (
    "id" SERIAL NOT NULL,
    "title" VARCHAR(255) NOT NULL,
    "description" JSONB,
    "year" INTEGER NOT NULL,
    "semester" "ProgressReportSemester" NOT NULL,
    "status" "ProgressReportStatus" NOT NULL DEFAULT 'DRAFT',
    "attachment" VARCHAR(500) NOT NULL,
    "draft_semester_report" VARCHAR(500),
    "final_semester_report" VARCHAR(500),
    "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_reports_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "progress_reports_user_id_idx" ON "progress_reports"("user_id");

-- CreateIndex
CREATE INDEX "progress_reports_year_idx" ON "progress_reports"("year");

-- CreateIndex
CREATE INDEX "progress_reports_semester_idx" ON "progress_reports"("semester");

-- CreateIndex
CREATE INDEX "progress_reports_status_idx" ON "progress_reports"("status");

-- CreateIndex
CREATE INDEX "progress_reports_deleted_at_idx" ON "progress_reports"("deleted_at");

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