Merge pull request #1092 from Tria-plc/freight_feature/usermanagement

expose per-side facility flags
This commit is contained in:
marshal
2026-08-03 11:59:11 +03:00
committed by GitHub

View File

@@ -0,0 +1,40 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
/**
* 3170 backfilled the per-side facility flags onto EXISTING yard_facilities
* rows, but the Djibouti port yards (Negad, the Doraleh terminals) are flagged
* `has_facility` without ever getting a facility record — the seeder only
* covers the inland intercity facilities. With the contract route picker now
* gating on the per-side flags, those yards report false on every side and
* vanish: import contracts lose all origin options, exports all destinations.
*
* Give every facility-flagged yard that has no live record one with both
* freight types open on both sides — exactly the offerability these yards had
* before the gate existed. Ops can narrow a port from the backoffice yards
* page, which now edits these flags.
*/
export class PortYardFacilityRecords3180000000000 implements MigrationInterface {
name = 'PortYardFacilityRecords3180000000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
INSERT INTO freight.yard_facilities
(yard_id, has_warehouse, handles_container, handles_bulk,
has_container_facility_origin, has_bulk_facility_origin,
has_container_facility_destination, has_bulk_facility_destination)
SELECT y.id, false, true, true, true, true, true, true
FROM freight.yards y
WHERE y.deleted_at IS NULL
AND y.has_facility = true
AND NOT EXISTS (
SELECT 1 FROM freight.yard_facilities f
WHERE f.yard_id = y.id AND f.deleted_at IS NULL
)
`);
}
public async down(): Promise<void> {
// Data seed — the inserted rows are indistinguishable from operator edits
// afterwards, so reversing would risk deleting real configuration.
}
}