import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * The booking wizard now captures a NON-BINDING estimated shipment date instead
 * of the binding scheduledDate. The binding scheduledDate (validated against
 * open train departures) is set later, at the operation-request step.
 */
export class AddEstimatedShipmentDate1820000000012
  implements MigrationInterface
{
  name = 'AddEstimatedShipmentDate1820000000012';

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

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