import { MigrationInterface, QueryRunner } from 'typeorm';

export class UpdateTableTransaction1719934464407 implements MigrationInterface {
  name = 'UpdateTableTransaction1719934464407';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transaction_items" ADD "item_hpp" bigint`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" ADD "item_category_id" character varying`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" ADD "item_category_name" character varying`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" ADD "item_bundlings" json`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."transactions_sending_invoice_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "sending_invoice_status" "public"."transactions_sending_invoice_status_enum"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "sending_invoice_at" bigint`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."transactions_sending_qr_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "sending_qr_status" "public"."transactions_sending_qr_status_enum"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "sending_qr_at" bigint`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "sending_qr_at"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "sending_qr_status"`,
    );
    await queryRunner.query(
      `DROP TYPE "public"."transactions_sending_qr_status_enum"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "sending_invoice_at"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "sending_invoice_status"`,
    );
    await queryRunner.query(
      `DROP TYPE "public"."transactions_sending_invoice_status_enum"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" DROP COLUMN "item_bundlings"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" DROP COLUMN "item_category_name"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" DROP COLUMN "item_category_id"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" DROP COLUMN "item_hpp"`,
    );
  }
}
