import { MigrationInterface, QueryRunner } from 'typeorm'; /** * Day-level booking pool: customers select a DAY (route + day), not a specific * train. The batch engine's pool query filters bookings on * (origin_yard_id, destination_yard_id, scheduled_date, status); this partial * index backs that scan. */ export class AddBookingRouteDayIndex1784100000000 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(` CREATE INDEX IF NOT EXISTS idx_bookings_route_day ON freight.bookings (origin_yard_id, destination_yard_id, scheduled_date, status) WHERE deleted_at IS NULL; `); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP INDEX IF EXISTS freight.idx_bookings_route_day;`); } }