mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 15:18:11 +00:00
feat: add per-ton cargo loading limits and update related services
This commit is contained in:
@@ -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"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user