/*
  Warnings:

  - A unique constraint covering the columns `[transactionId]` on the table `Payment` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `filename` to the `Payment` table without a default value. This is not possible if the table is not empty.
  - Added the required column `mimetype` to the `Payment` table without a default value. This is not possible if the table is not empty.
  - Added the required column `size` to the `Payment` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "NoteEntityType" AS ENUM ('TRANSACTION', 'TRANSACTION_ITEM', 'PAYMENT');

-- CreateEnum
CREATE TYPE "NoteType" AS ENUM ('STATUS_CHANGE', 'REJECTION', 'ROLLBACK', 'ITEM_ADJUSTMENT', 'GENERAL');

-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.


ALTER TYPE "TransactionStatus" ADD VALUE 'PAID_WAITING_HS_REVIEW';
ALTER TYPE "TransactionStatus" ADD VALUE 'REJECTED';

-- AlterTable
ALTER TABLE "Payment" ADD COLUMN     "filename" TEXT NOT NULL,
ADD COLUMN     "mimetype" TEXT NOT NULL,
ADD COLUMN     "size" INTEGER NOT NULL;

-- CreateTable
CREATE TABLE "note" (
    "id" UUID NOT NULL,
    "entityType" "NoteEntityType" NOT NULL,
    "entityId" UUID NOT NULL,
    "type" "NoteType" NOT NULL,
    "content" TEXT NOT NULL,
    "createdBy" UUID NOT NULL,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "TxnRunum" (
    "id" UUID NOT NULL,
    "runumId" TEXT NOT NULL,
    "reset" TEXT NOT NULL,
    "nid" INTEGER NOT NULL DEFAULT 0,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "modified_at" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE INDEX "note_entityType_entityId_idx" ON "note"("entityType", "entityId");

-- CreateIndex
CREATE UNIQUE INDEX "Payment_transactionId_key" ON "Payment"("transactionId");
