import { MigrationInterface, QueryRunner } from "typeorm";

/**
 * Track per-booking loading confirmation (LOADED/UNLOADED) on train_schedule_bookings.
 * Tracking only — does not gate dispatch.
 */
export class AddLoadingStatusToTrainScheduleBookings1900000000000
  implements MigrationInterface
{
  name = "AddLoadingStatusToTrainScheduleBookings1900000000000";

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      ALTER TABLE freight.train_schedule_bookings
      ADD COLUMN IF NOT EXISTS loading_status varchar(20) NOT NULL DEFAULT 'UNLOADED'
    `);
  }

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