import { MigrationInterface, QueryRunner } from "typeorm";

export class AddETradeFieldsToCompanies1791000000003
  implements MigrationInterface
{
  name = "AddETradeFieldsToCompanies1791000000003";

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS licence_number varchar(100);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS status_description text;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS date_registered varchar(50);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS renewed_from varchar(50);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS renewal_date varchar(50);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS renewed_to varchar(50);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS region varchar(100);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS zone varchar(100);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS woreda varchar(100);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS kebele varchar(100);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS house_no varchar(100);
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        ADD COLUMN IF NOT EXISTS etrade_phone varchar(20);
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS licence_number;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS status_description;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS date_registered;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS renewed_from;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS renewal_date;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS renewed_to;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS region;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS zone;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS woreda;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS kebele;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS house_no;
    `);
    await queryRunner.query(`
      ALTER TABLE freight.companies
        DROP COLUMN IF EXISTS etrade_phone;
    `);
  }
}
