import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Truck-detention rules can be scoped by vehicle type (TRUCK / VAN / TRAILER /
 * TANKER / FLATBED / …), so different truck types carry different detention
 * rates. Null = applies to any truck type.
 */
export class AddFeeRuleVehicleType2010000000000 implements MigrationInterface {
  name = 'AddFeeRuleVehicleType2010000000000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE freight.warehouse_fee_rules ADD COLUMN IF NOT EXISTS vehicle_type varchar(20)`,
    );
  }

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