import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TYPE "public"."otp_verifications_action_type_enum" RENAME TO "otp_verifications_action_type_enum_old"`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."otp_verifications_action_type_enum" AS ENUM('CREATE_DISCOUNT', 'CANCEL_TRANSACTION', 'REJECT_RECONCILIATION')`,
    );
    await queryRunner.query(
      `ALTER TABLE "otp_verifications" ALTER COLUMN "action_type" TYPE "public"."otp_verifications_action_type_enum" USING "action_type"::"text"::"public"."otp_verifications_action_type_enum"`,
    );
    await queryRunner.query(
      `DROP TYPE "public"."otp_verifications_action_type_enum_old"`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."otp_verifications_action_type_enum_old" AS ENUM('CREATE_DISCOUNT', 'CANCEL_TRANSACTION')`,
    );
    await queryRunner.query(
      `ALTER TABLE "otp_verifications" ALTER COLUMN "action_type" TYPE "public"."otp_verifications_action_type_enum_old" USING "action_type"::"text"::"public"."otp_verifications_action_type_enum_old"`,
    );
    await queryRunner.query(
      `DROP TYPE "public"."otp_verifications_action_type_enum"`,
    );
    await queryRunner.query(
      `ALTER TYPE "public"."otp_verifications_action_type_enum_old" RENAME TO "otp_verifications_action_type_enum"`,
    );
  }
}
