feat: add per-ton cargo loading limits and update related services

This commit is contained in:
Marshal
2026-08-03 19:16:28 +00:00
parent 9afc281d21
commit 488c2465be
14 changed files with 394 additions and 21 deletions

View File

@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
/**
* PER_TON (bulk) cargo can have a loading limit BELOW the wagon's rated
* capacity: sugar rides 50T on a 70T wagon (density/stowage/policy), so 200T
* needs 4 wagons, not the 3 that raw capacity implies. Stored as a jsonb map
* { [wagonTypeId]: maxTons } on cargo_types — the PER_TON mirror of
* items_per_wagon_map. Unset (or no key) means the wagon's full rated capacity,
* so existing cargo types keep their current behaviour with no backfill.
*/
export class AddCargoTypeTonsPerWagonMap3190000000000 implements MigrationInterface {
name = 'AddCargoTypeTonsPerWagonMap3190000000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "freight"."cargo_types" ADD COLUMN IF NOT EXISTS "tons_per_wagon_map" jsonb`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "freight"."cargo_types" DROP COLUMN IF EXISTS "tons_per_wagon_map"`,
);
}
}