-- CreateEnum CREATE TYPE "DealReportReason" AS ENUM ('EXPIRED', 'WRONG_PRICE', 'MISLEADING', 'SPAM', 'OTHER'); -- CreateEnum CREATE TYPE "DealReportStatus" AS ENUM ('OPEN', 'REVIEWED', 'CLOSED'); -- DropIndex DROP INDEX "Deal_description_trgm_idx"; -- DropIndex DROP INDEX "Deal_title_trgm_idx"; -- CreateTable CREATE TABLE "DealReport" ( "id" SERIAL NOT NULL, "dealId" INTEGER NOT NULL, "userId" INTEGER NOT NULL, "reason" "DealReportReason" NOT NULL, "note" TEXT, "status" "DealReportStatus" NOT NULL DEFAULT 'OPEN', "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL, CONSTRAINT "DealReport_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE INDEX "DealReport_dealId_createdAt_idx" ON "DealReport"("dealId", "createdAt"); -- CreateIndex CREATE INDEX "DealReport_userId_createdAt_idx" ON "DealReport"("userId", "createdAt"); -- CreateIndex CREATE INDEX "DealReport_status_createdAt_idx" ON "DealReport"("status", "createdAt"); -- CreateIndex CREATE UNIQUE INDEX "DealReport_dealId_userId_key" ON "DealReport"("dealId", "userId"); -- AddForeignKey ALTER TABLE "DealReport" ADD CONSTRAINT "DealReport_dealId_fkey" FOREIGN KEY ("dealId") REFERENCES "Deal"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "DealReport" ADD CONSTRAINT "DealReport_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;