Skip to main content
Version: v1.0.0(int)

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

ColumnTypeNotes
idUUID PK
org_idUUID FKplatform.organizations(id).
sku_idUUID FKNOT NULL. → org.skus(id) ON DELETE CASCADE. The output SKU this BOM produces.
material_idUUID FKorg.materials(id) ON DELETE RESTRICT. Input — XOR with input_sku_id.
input_sku_idUUID FKorg.skus(id) ON DELETE RESTRICT. Input — XOR with material_id. (FG-as-input.)
quantityNUMERIC(18,6)NOT NULL. CHECK > 0. Decimals allowed.
created_atTIMESTAMPTZNOT 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_id is 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_inputs at WO creation.