mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
Truck detention on lastmile
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Truck detention support.
|
||||
* - last_mile.arrived_at / delivered_at: the detention window for an EDR
|
||||
* last-mile vehicle. The clock runs from arrival at destination; the customer
|
||||
* has a grace period (default 3h) to clear/return, after which detention
|
||||
* accrues per truck per day until delivered_at (or now, if still out).
|
||||
* - warehouse_fee_rules.free_hours: configurable grace window (hours) for a
|
||||
* TRUCK_DETENTION_FEE rule; null/0 falls back to the 3-hour default.
|
||||
*/
|
||||
export class AddTruckDetentionTiming2000000000000 implements MigrationInterface {
|
||||
name = 'AddTruckDetentionTiming2000000000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.last_mile ADD COLUMN IF NOT EXISTS arrived_at timestamptz`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.last_mile ADD COLUMN IF NOT EXISTS delivered_at timestamptz`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE freight.warehouse_fee_rules ADD COLUMN IF NOT EXISTS free_hours int`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE freight.warehouse_fee_rules DROP COLUMN IF EXISTS free_hours`);
|
||||
await queryRunner.query(`ALTER TABLE freight.last_mile DROP COLUMN IF EXISTS delivered_at`);
|
||||
await queryRunner.query(`ALTER TABLE freight.last_mile DROP COLUMN IF EXISTS arrived_at`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user