Warehouse Inventory Sync Overwrites the Same SKU in Another Warehouse
Level 2 · node · Data · Missing composite identifier
Scenario
A logistics system synchronizes external inventory snapshots by warehouse. The same SKU can exist in multiple warehouses, and each warehouse quantity must be managed independently. Updating an existing SKU in one warehouse appears to work, but operations reports that when the same SKU exists in another warehouse, synchronization changes or removes the quantity belonging to one side. The sync service and inventory repository are separated.
Requirements
- Inventory rows are identified by the warehouseId and sku combination - Synchronizing an existing SKU in the same warehouse updates only that row quantity - Rows for the same SKU in different warehouses remain independent - A previously unseen warehouseId and sku combination is inserted as a new row - Applying multiple snapshots in sequence preserves the final quantity for every warehouse
Acceptance criteria
- An existing SKU quantity in an existing warehouse is updated correctly
- A new SKU is inserted as a new inventory row for that warehouse
- Synchronizing the same SKU to another warehouse does not change the existing warehouse row
- The same SKU in two different warehouses keeps an independent quantity in each
- After sequential synchronization, the final state for each warehouseId and sku combination is correct