/*
  Warnings:

  - You are about to drop the column `accountId` on the `account_finanace_request` table. All the data in the column will be lost.
  - You are about to drop the column `amount` on the `account_finanace_request` table. All the data in the column will be lost.
  - You are about to drop the column `type` on the `account_finanace_request` table. All the data in the column will be lost.

*/
-- CreateEnum
CREATE TYPE "TopUpType" AS ENUM ('TOP_UP', 'WITHDRAW');

-- DropForeignKey
ALTER TABLE "account_finanace_request" DROP CONSTRAINT "account_finanace_request_accountId_fkey";

-- AlterTable
ALTER TABLE "account_finanace_request" DROP COLUMN "accountId",
DROP COLUMN "amount",
DROP COLUMN "type";

-- CreateTable
CREATE TABLE "top_up" (
    "id" SERIAL NOT NULL,
    "createDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "amount" INTEGER NOT NULL,
    "type" "TopUpType" NOT NULL,
    "requestId" INTEGER NOT NULL,
    "accountId" INTEGER NOT NULL,

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

-- AddForeignKey
ALTER TABLE "top_up" ADD CONSTRAINT "top_up_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "account_finanace_request"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "top_up" ADD CONSTRAINT "top_up_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
