import { AppDataSource } from '../data-source'; import { WarehouseLayoutSeeder } from '../seed/warehouse-layout.seeder'; /** * Lays out the physical warehouse structure described by * `src/seed/warehouse-layout.json` — edit that file, not this script. * * Idempotent: existing warehouses, yards, zones, stacks and slots are left * untouched, so a re-run only fills in what is missing. */ async function seedWarehouseLayout() { await AppDataSource.initialize(); try { const summary = await new WarehouseLayoutSeeder(AppDataSource).run(); console.table([summary]); const counts = await AppDataSource.query(` SELECT (SELECT COUNT(*)::int FROM freight.warehouses WHERE deleted_at IS NULL) AS warehouses, (SELECT COUNT(*)::int FROM freight.warehouse_yards WHERE deleted_at IS NULL) AS yards, (SELECT COUNT(*)::int FROM freight.warehouse_zones WHERE deleted_at IS NULL) AS zones, (SELECT COUNT(*)::int FROM freight.warehouse_zone_stacks WHERE deleted_at IS NULL) AS stacks, (SELECT COUNT(*)::int FROM freight.warehouse_zone_slots WHERE deleted_at IS NULL) AS slots `); console.table(counts); } finally { await AppDataSource.destroy(); } } seedWarehouseLayout().catch((error) => { console.error('Failed to seed the warehouse layout:', error); process.exit(1); });