import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."payment_methods_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'pending', 'refunded', 'rejected', 'settled', 'waiting')`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."payment_methods_type_enum" AS ENUM('bank transfer', 'e-wallet', 'edc')`,
    );
    await queryRunner.query(
      `CREATE TABLE "payment_methods" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."payment_methods_status_enum" NOT NULL DEFAULT 'draft', "issuer_name" character varying NOT NULL, "account_number" character varying, "account_name" character varying, "qr_image" character varying, "note" character varying, "type" "public"."payment_methods_type_enum" NOT NULL DEFAULT 'bank transfer', CONSTRAINT "PK_34f9b8c6dfb4ac3559f7e2820d1" PRIMARY KEY ("id"))`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`DROP TABLE "payment_methods"`);
    await queryRunner.query(`DROP TYPE "public"."payment_methods_type_enum"`);
    await queryRunner.query(`DROP TYPE "public"."payment_methods_status_enum"`);
  }
}
