import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddDistanceColumnsToVehicles1821000000002 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.vehicles
        ADD COLUMN IF NOT EXISTS estimated_distance_km NUMERIC,
        ADD COLUMN IF NOT EXISTS actual_distance_km NUMERIC;
    `);
  }

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