Files
edr-platform/apps/edr-freight-api/src/migrations/3070000000000-AddBulkTotalWeightTons.ts
2026-07-30 11:30:34 +00:00

26 lines
985 B
TypeScript

import { MigrationInterface, QueryRunner } from 'typeorm';
/**
* Break-bulk (PER_ITEM) bookings store their item count in
* cargo_total_weight_vgm, so the actual tonnage was never captured — wagon
* allocation divided an item COUNT by a tons capacity and under-allocated
* (400 machines ÷ 69T wagon read as 6 wagons instead of 12). New column holds
* the real total weight in tons for PER_ITEM cargo; null for PER_TON bulk and
* container bookings.
*/
export class AddBulkTotalWeightTons3070000000000 implements MigrationInterface {
name = 'AddBulkTotalWeightTons3070000000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE freight.bookings ADD COLUMN IF NOT EXISTS bulk_total_weight_tons numeric(12,3);`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE freight.bookings DROP COLUMN IF EXISTS bulk_total_weight_tons;`,
);
}
}