import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "is_recap_transaction" boolean NOT NULL DEFAULT true`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "payment_type_method_number" character varying`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "reconciliation_mdr" numeric`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."transactions_reconciliation_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "reconciliation_status" "public"."transactions_reconciliation_status_enum" NOT NULL DEFAULT 'draft'`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "reconciliation_confirm_date" character varying`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "reconciliation_confirm_by" character varying`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" ADD "payment_total_net_profit" numeric`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "payment_total_net_profit"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "reconciliation_confirm_by"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "reconciliation_confirm_date"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "reconciliation_status"`,
    );
    await queryRunner.query(
      `DROP TYPE "public"."transactions_reconciliation_status_enum"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "reconciliation_mdr"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "payment_type_method_number"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "is_recap_transaction"`,
    );
  }
}
