org.bom_items
The composition that links input materials and/or input SKUs (with quantities) to an output SKU. One row per (output SKU × input). Polymorphic on the input side because materials and SKUs are kept separate.
ER diagram
Columns
| Column | Type | Notes |
|---|---|---|
id | UUID PK | |
org_id | UUID FK | → platform.organizations(id). |
sku_id | UUID FK | NOT NULL. → org.skus(id) ON DELETE CASCADE. The output SKU this BOM produces. |
material_id | UUID FK | → org.materials(id) ON DELETE RESTRICT. Input — XOR with input_sku_id. |
input_sku_id | UUID FK | → org.skus(id) ON DELETE RESTRICT. Input — XOR with material_id. (FG-as-input.) |
quantity | NUMERIC(18,6) | NOT NULL. CHECK > 0. Decimals allowed. |
created_at | TIMESTAMPTZ | NOT NULL. Default NOW(). |
Rows are immutable — no updated_at. Recipe changes are delete-and-replace.
Constraints
- Input XOR:
((material_id IS NOT NULL AND input_sku_id IS NULL) OR (material_id IS NULL AND input_sku_id IS NOT NULL)). Exactly one of the two input FKs is set. - No self-reference:
input_sku_id IS NULL OR input_sku_id <> sku_id. - UNIQUE
(sku_id, COALESCE(material_id, input_sku_id))— one row per (output SKU, input).
Cross-references
- Output side: every row's
sku_idis one of the SKUs. - Input side: each row references either a material or another SKU.
- BOMs drive cost cascades and WO consumption logic in L3.
- Snapshotted into
work_order_inputsat WO creation.