mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 21:48:18 +00:00
Join truck_types via vehicles.truck_type_id (normalized legacy vehicle_type only as fallback) so type renames can't unmatch detention rules and FK-less vehicles keep billing.
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
/**
|
|
* Bulk tonnage at assignment time. First-mile trucks and export self-haul
|
|
* trucks carry a planned load (tonnes + optional item count) so bulk bookings
|
|
* draw down as vehicles are assigned — not only at the weighbridge.
|
|
*/
|
|
export class AddMileTonsQuantity2820000000000 implements MigrationInterface {
|
|
name = 'AddMileTonsQuantity2820000000000';
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.first_mile_vehicle_assignments ADD COLUMN IF NOT EXISTS tons numeric(14,3);`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.first_mile_vehicle_assignments ADD COLUMN IF NOT EXISTS quantity integer;`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.customer_truck_assignments ADD COLUMN IF NOT EXISTS planned_tons numeric(14,3);`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.customer_truck_assignments ADD COLUMN IF NOT EXISTS planned_quantity integer;`,
|
|
);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.customer_truck_assignments DROP COLUMN IF EXISTS planned_quantity;`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.customer_truck_assignments DROP COLUMN IF EXISTS planned_tons;`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.first_mile_vehicle_assignments DROP COLUMN IF EXISTS quantity;`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE freight.first_mile_vehicle_assignments DROP COLUMN IF EXISTS tons;`,
|
|
);
|
|
}
|
|
}
|