-- CreateTable
CREATE TABLE "upgrade_request" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "targetPlan" TEXT NOT NULL DEFAULT 'PREMIUM',
    "contact" TEXT,
    "note" TEXT,
    "status" TEXT NOT NULL DEFAULT 'PENDING',
    "amountVnd" INTEGER,
    "paymentRef" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "resolvedAt" TIMESTAMP(3),
    "resolvedBy" TEXT,

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

-- CreateIndex
CREATE INDEX "upgrade_request_userId_createdAt_idx" ON "upgrade_request"("userId", "createdAt");

-- CreateIndex
CREATE INDEX "upgrade_request_status_createdAt_idx" ON "upgrade_request"("status", "createdAt");

-- AddForeignKey
ALTER TABLE "upgrade_request" ADD CONSTRAINT "upgrade_request_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
