/*
  Warnings:

  - You are about to drop the column `docType` on the `TransactionItemDoc` table. All the data in the column will be lost.
  - You are about to drop the column `fileUrl` on the `TransactionItemDoc` table. All the data in the column will be lost.
  - Added the required column `filename` to the `TransactionItemDoc` table without a default value. This is not possible if the table is not empty.
  - Added the required column `mimetype` to the `TransactionItemDoc` table without a default value. This is not possible if the table is not empty.
  - Added the required column `size` to the `TransactionItemDoc` table without a default value. This is not possible if the table is not empty.
  - Added the required column `type` to the `TransactionItemDoc` table without a default value. This is not possible if the table is not empty.
  - Added the required column `url` to the `TransactionItemDoc` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "TransactionDocType" AS ENUM ('SERAH_TERIMA', 'SURAT_PERNYATAAN', 'BUKTI_TRANSFER');

-- AlterTable
ALTER TABLE "Transaction" ADD COLUMN     "bank_account_name" TEXT,
ADD COLUMN     "bank_account_no" TEXT,
ADD COLUMN     "bank_id" UUID;

-- AlterTable
ALTER TABLE "TransactionItemDoc" DROP COLUMN "docType",
DROP COLUMN "fileUrl",
ADD COLUMN     "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN     "filename" TEXT NOT NULL,
ADD COLUMN     "mimetype" TEXT NOT NULL,
ADD COLUMN     "order" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN     "size" INTEGER NOT NULL,
ADD COLUMN     "type" TEXT NOT NULL,
ADD COLUMN     "url" TEXT NOT NULL;

-- DropEnum
DROP TYPE "MaterialType";

-- CreateTable
CREATE TABLE "bank" (
    "id" UUID NOT NULL,
    "code" VARCHAR(50) NOT NULL,
    "name" VARCHAR(100) NOT NULL,
    "status" "SettingStatus" NOT NULL DEFAULT 'ACTIVE',
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "modified_at" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "transaction_doc" (
    "id" UUID NOT NULL,
    "transaction_id" TEXT NOT NULL,
    "type" "TransactionDocType" NOT NULL,
    "url" TEXT NOT NULL,
    "filename" TEXT NOT NULL,
    "mimetype" TEXT NOT NULL,
    "size" INTEGER NOT NULL,
    "order" INTEGER NOT NULL DEFAULT 0,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE UNIQUE INDEX "bank_code_key" ON "bank"("code");

-- AddForeignKey
ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_bank_id_fkey" FOREIGN KEY ("bank_id") REFERENCES "bank"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "transaction_doc" ADD CONSTRAINT "transaction_doc_transaction_id_fkey" FOREIGN KEY ("transaction_id") REFERENCES "Transaction"("id") ON DELETE CASCADE ON UPDATE CASCADE;
