mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 10:58:14 +00:00
- Added a reason field to train history entries for detach/maintenance actions. - Updated TrainHistoryPanel to display the reason for wagon detachments. - Introduced per-wagon load/unload functionality in ScheduleWorkspacePanel with a modal for managing individual wagons. - Implemented API endpoints for loading and unloading specific wagons, including the ability to cancel remaining wagons with a reason. - Refactored detach request handling in TrainBuilderDetailPage to streamline the process and remove the approval flow, requiring a reason for detachments. - Updated types and services to support new wagon loading/unloading features and booking wagon retrieval.
66 lines
2.5 KiB
TypeScript
66 lines
2.5 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||
|
||
/**
|
||
* Per-wagon loading. Staff may confirm loading wagon-by-wagon instead of the
|
||
* whole booking at once:
|
||
* - bookings.loading_started_at — first wagon loaded; the booking stays PAID
|
||
* until every remaining wagon is LOADED (remaining = allocated − cancelled).
|
||
* Also shields a mid-load booking from the dispatch "left behind" unassign.
|
||
* - wagon_booking_allocations.loaded_at / loaded_by_user_id — per-wagon
|
||
* confirmation audit.
|
||
* - booking_wagon_cancellations.fault — who caused an at-loading cancel of
|
||
* the never-loaded remainder: CUSTOMER (fee applies) or EDR (no fee, credit
|
||
* rebookable in full).
|
||
*/
|
||
export class PerWagonLoading3760000000000 implements MigrationInterface {
|
||
name = 'PerWagonLoading3760000000000';
|
||
|
||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.bookings
|
||
ADD COLUMN IF NOT EXISTS loading_started_at timestamptz`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations
|
||
ADD COLUMN IF NOT EXISTS loaded_at timestamptz`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations
|
||
ADD COLUMN IF NOT EXISTS loaded_by_user_id uuid`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations
|
||
ADD COLUMN IF NOT EXISTS unloaded_at timestamptz`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations
|
||
ADD COLUMN IF NOT EXISTS unloaded_by_user_id uuid`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.booking_wagon_cancellations
|
||
ADD COLUMN IF NOT EXISTS fault varchar(16)`,
|
||
);
|
||
}
|
||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.booking_wagon_cancellations DROP COLUMN IF EXISTS fault`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations DROP COLUMN IF EXISTS loaded_by_user_id`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations DROP COLUMN IF EXISTS unloaded_by_user_id`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations DROP COLUMN IF EXISTS unloaded_at`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.wagon_booking_allocations DROP COLUMN IF EXISTS loaded_at`,
|
||
);
|
||
await queryRunner.query(
|
||
`ALTER TABLE freight.bookings DROP COLUMN IF EXISTS loading_started_at`,
|
||
);
|
||
}
|
||
}
|