import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "queues" ADD "creator_id" character varying(36)`,
    );
    await queryRunner.query(
      `ALTER TABLE "queues" ADD "creator_name" character varying(125)`,
    );
    await queryRunner.query(
      `ALTER TABLE "queues" ADD "editor_id" character varying(36)`,
    );
    await queryRunner.query(
      `ALTER TABLE "queues" ADD "editor_name" character varying(125)`,
    );
    await queryRunner.query(
      `ALTER TABLE "queues" ADD "created_at" bigint NOT NULL`,
    );
    await queryRunner.query(
      `ALTER TABLE "queues" ADD "updated_at" bigint NOT NULL`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "queues" ALTER COLUMN "call_time" DROP NOT NULL`,
    );

    await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "updated_at"`);
    await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "created_at"`);
    await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "editor_name"`);
    await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "editor_id"`);
    await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "creator_name"`);
    await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "creator_id"`);
  }
}
