import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."refunds_refund_reason_type_enum" AS ENUM('weather', 'ride malfunction', 'other')`,
    );
    await queryRunner.query(
      `ALTER TABLE "refunds" ADD "refund_reason_type" "public"."refunds_refund_reason_type_enum" NOT NULL DEFAULT 'ride malfunction'`,
    );
    await queryRunner.query(`ALTER TABLE "refunds" ADD "refund_reason" text`);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "refunds" DROP COLUMN "refund_reason"`,
    );
    await queryRunner.query(
      `ALTER TABLE "refunds" DROP COLUMN "refund_reason_type"`,
    );
    await queryRunner.query(
      `DROP TYPE "public"."refunds_refund_reason_type_enum"`,
    );
  }
}
