import { MigrationInterface, QueryRunner } from "typeorm"; /** * Loading and unloading times, on the stop that already records the train * standing at a station. * * The OCC report publishes, per train, "total loading and unloading time" and * the "other activity" left over from the station stay. Nothing recorded when * handling started or ended — the July 2026 seed had to write the figure into * a checkpoint's note — so the staying-time report could only ever publish the * whole stay. * * These four go on `train_checkpoint_events` rather than a table of their own: * a stop is already one row there, keyed (schedule, sequence_no), and the * arrival row is the one the staying-time report builds a stay from. All four * are nullable — a stop where nobody logged the handling still reports its * staying time, with the handling columns empty rather than zero. */ export class CheckpointHandlingTimes3690000000000 implements MigrationInterface { name = "CheckpointHandlingTimes3690000000000"; public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(` ALTER TABLE freight.train_checkpoint_events ADD COLUMN IF NOT EXISTS unloading_started_at timestamptz, ADD COLUMN IF NOT EXISTS unloading_completed_at timestamptz, ADD COLUMN IF NOT EXISTS loading_started_at timestamptz, ADD COLUMN IF NOT EXISTS loading_completed_at timestamptz; `); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(` ALTER TABLE freight.train_checkpoint_events DROP COLUMN IF EXISTS unloading_started_at, DROP COLUMN IF EXISTS unloading_completed_at, DROP COLUMN IF EXISTS loading_started_at, DROP COLUMN IF EXISTS loading_completed_at; `); } }