-- CreateTable
CREATE TABLE "progress_report_update_issues" (
    "id" SERIAL NOT NULL,
    "progress_report_update_id" INTEGER NOT NULL,
    "ministry_id" INTEGER NOT NULL,
    "issue_id" INTEGER NOT NULL,

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

-- CreateIndex
CREATE INDEX "progress_report_update_issues_progress_report_update_id_idx" ON "progress_report_update_issues"("progress_report_update_id");

-- CreateIndex
CREATE INDEX "progress_report_update_issues_ministry_id_idx" ON "progress_report_update_issues"("ministry_id");

-- CreateIndex
CREATE INDEX "progress_report_update_issues_issue_id_idx" ON "progress_report_update_issues"("issue_id");

-- CreateIndex
CREATE UNIQUE INDEX "progress_report_update_issues_progress_report_update_id_min_key" ON "progress_report_update_issues"("progress_report_update_id", "ministry_id", "issue_id");

-- AddForeignKey
ALTER TABLE "progress_report_update_issues" ADD CONSTRAINT "progress_report_update_issues_progress_report_update_id_fkey" FOREIGN KEY ("progress_report_update_id") REFERENCES "progress_report_updates"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "progress_report_update_issues" ADD CONSTRAINT "progress_report_update_issues_ministry_id_fkey" FOREIGN KEY ("ministry_id") REFERENCES "stakeholders"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "progress_report_update_issues" ADD CONSTRAINT "progress_report_update_issues_issue_id_fkey" FOREIGN KEY ("issue_id") REFERENCES "issues"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
