/*
  Warnings:

  - A unique constraint covering the columns `[name]` on the table `comment_types` will be added. If there are existing duplicate values, this will fail.

*/
-- CreateTable
CREATE TABLE "progress_report_issue_comments" (
    "id" SERIAL NOT NULL,
    "comment_type_id" INTEGER NOT NULL,
    "progress_report_update_issue_id" INTEGER NOT NULL,
    "comment" JSONB,
    "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_issue_comments_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "progress_report_issue_comments_comment_type_id_idx" ON "progress_report_issue_comments"("comment_type_id");

-- CreateIndex
CREATE INDEX "progress_report_issue_comments_progress_report_update_issue_idx" ON "progress_report_issue_comments"("progress_report_update_issue_id");

-- CreateIndex
CREATE INDEX "progress_report_issue_comments_user_id_idx" ON "progress_report_issue_comments"("user_id");

-- CreateIndex
CREATE INDEX "progress_report_issue_comments_deleted_at_idx" ON "progress_report_issue_comments"("deleted_at");

-- CreateIndex
CREATE INDEX "comment_types_deleted_at_idx" ON "comment_types"("deleted_at");

-- CreateIndex
CREATE UNIQUE INDEX "comment_types_name_key" ON "comment_types"("name");

-- AddForeignKey
ALTER TABLE "progress_report_issue_comments" ADD CONSTRAINT "progress_report_issue_comments_comment_type_id_fkey" FOREIGN KEY ("comment_type_id") REFERENCES "comment_types"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

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

-- AddForeignKey
ALTER TABLE "progress_report_issue_comments" ADD CONSTRAINT "progress_report_issue_comments_progress_report_update_issu_fkey" FOREIGN KEY ("progress_report_update_issue_id") REFERENCES "progress_report_update_issues"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
