import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    // fan_number may already exist when CreateCompaniesModule ran with the full schema
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS fan_number varchar(16) NULL;
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS fan_number;
    `);
  }
}
