import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Every new wagon-transfer request must state WHY the wagons are needed; the
 * reason is shown on the OCC request queue. Nullable in the DB — legacy rows
 * predate the requirement; the DTO enforces it for new requests.
 */
export class AddTransferRequestReason2240000000000 implements MigrationInterface {
  name = 'AddTransferRequestReason2240000000000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.wagon_transfer_requests
        ADD COLUMN IF NOT EXISTS reason text NULL
    `);
  }

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