-- CreateTable
CREATE TABLE "DealerNote" (
    "id" TEXT NOT NULL,
    "dealerId" TEXT NOT NULL,
    "adminId" TEXT NOT NULL,
    "content" TEXT NOT NULL,
    "noteType" TEXT NOT NULL,
    "isAutomatic" BOOLEAN NOT NULL DEFAULT false,
    "metadata" JSONB,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "updatedBy" TEXT,

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

-- CreateIndex
CREATE INDEX "DealerNote_dealerId_idx" ON "DealerNote"("dealerId");

-- CreateIndex
CREATE INDEX "DealerNote_createdAt_idx" ON "DealerNote"("createdAt");

-- CreateIndex
CREATE INDEX "DealerNote_adminId_idx" ON "DealerNote"("adminId");

-- AddForeignKey
ALTER TABLE "DealerNote" ADD CONSTRAINT "DealerNote_dealerId_fkey" FOREIGN KEY ("dealerId") REFERENCES "Dealer"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "DealerNote" ADD CONSTRAINT "DealerNote_adminId_fkey" FOREIGN KEY ("adminId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
