-- CreateTable
CREATE TABLE "PaymentRequest" (
    "id" SERIAL NOT NULL,
    "txnId" VARCHAR(255) NOT NULL,
    "studentId" INTEGER NOT NULL,
    "subjectId" INTEGER NOT NULL,
    "amount" INTEGER NOT NULL,
    "status" VARCHAR(20) DEFAULT 'pending',
    "proofImage" TEXT,
    "createdAt" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
    "approvedAt" TIMESTAMP(6),

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

-- CreateIndex
CREATE UNIQUE INDEX "PaymentRequest_txnId_key" ON "PaymentRequest"("txnId");

-- AddForeignKey
ALTER TABLE "PaymentRequest" ADD CONSTRAINT "fk_student" FOREIGN KEY ("studentId") REFERENCES "User"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- AddForeignKey
ALTER TABLE "PaymentRequest" ADD CONSTRAINT "fk_subject" FOREIGN KEY ("subjectId") REFERENCES "Subject"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
