import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `CREATE TYPE "public"."item_queues_usage_type_enum" AS ENUM('one_time', 'multiple')`,
    );
    await queryRunner.query(
      `ALTER TABLE "item_queues" ADD "usage_type" "public"."item_queues_usage_type_enum" NOT NULL DEFAULT 'one_time'`,
    );
    await queryRunner.query(
      `CREATE TYPE "public"."items_usage_type_enum" AS ENUM('one_time', 'multiple')`,
    );
    await queryRunner.query(
      `ALTER TABLE "items" ADD "usage_type" "public"."items_usage_type_enum" NOT NULL DEFAULT 'one_time'`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "usage_type"`);
    await queryRunner.query(`DROP TYPE "public"."items_usage_type_enum"`);
    await queryRunner.query(
      `ALTER TABLE "item_queues" DROP COLUMN "usage_type"`,
    );
    await queryRunner.query(`DROP TYPE "public"."item_queues_usage_type_enum"`);
  }
}
