per-user trade-direction access scope

This commit is contained in:
Marshal
2026-08-02 22:29:58 +00:00
parent c055abe8c1
commit f4fd469643
47 changed files with 1451 additions and 107 deletions

View File

@@ -59,14 +59,23 @@ export class YardFacilitiesSeeder {
[yard.id],
);
// Every facility works both sides of the trip today, so the per-side
// flags mirror the freight-type flags. Narrow an individual yard here
// when a real one turns out to load a type but not receive it.
await this.dataSource.query(
`INSERT INTO freight.yard_facilities
(yard_id, has_warehouse, handles_container, handles_bulk, equipment_notes)
VALUES ($1, $2, $3, true, $4)
(yard_id, has_warehouse, handles_container, handles_bulk, equipment_notes,
has_container_facility_origin, has_container_facility_destination,
has_bulk_facility_origin, has_bulk_facility_destination)
VALUES ($1, $2, $3, true, $4, $3, $3, true, true)
ON CONFLICT (yard_id) WHERE deleted_at IS NULL
DO UPDATE SET has_warehouse = EXCLUDED.has_warehouse,
handles_container = EXCLUDED.handles_container,
handles_bulk = EXCLUDED.handles_bulk,
has_container_facility_origin = EXCLUDED.has_container_facility_origin,
has_container_facility_destination = EXCLUDED.has_container_facility_destination,
has_bulk_facility_origin = EXCLUDED.has_bulk_facility_origin,
has_bulk_facility_destination = EXCLUDED.has_bulk_facility_destination,
updated_at = NOW()`,
[yard.id, hasWarehouse, handlesContainer, `${facility} load/unload facility`],
);