import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Drops wagon_types.max_wagons_per_train. Train wagon-count caps are already
 * derived from locomotive + wagon length/weight (train-capacity.util.ts) and
 * the global train_scheduling_global_rules row — this per-wagon-type override
 * was unused by that derivation and only added a confusing "Max / train"
 * field to the wagon type form.
 */
export class DropWagonTypeMaxWagonsPerTrain2050000000000
  implements MigrationInterface
{
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.wagon_types
        DROP COLUMN IF EXISTS max_wagons_per_train;
    `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.wagon_types
        ADD COLUMN IF NOT EXISTS max_wagons_per_train INT;
    `);
  }
}
