Widen production__work_order.status CHECK to allow IN_PROGRESS ALTER TABLE production__work_order DROP CONSTRAINT production__work_order_status_check; ALTER TABLE production__work_order ADD CONSTRAINT production__work_order_status_check CHECK (status IN ('DRAFT', 'IN_PROGRESS', 'COMPLETED', 'CANCELLED')); ALTER TABLE production__work_order DROP CONSTRAINT production__work_order_status_check; ALTER TABLE production__work_order ADD CONSTRAINT production__work_order_status_check CHECK (status IN ('DRAFT', 'COMPLETED', 'CANCELLED')); Create production__work_order_input (BOM child table) CREATE TABLE production__work_order_input ( id uuid PRIMARY KEY, work_order_id uuid NOT NULL REFERENCES production__work_order(id) ON DELETE CASCADE, line_no integer NOT NULL, item_code varchar(64) NOT NULL, quantity_per_unit numeric(18,4) NOT NULL, source_location_code varchar(64) NOT NULL, created_at timestamptz NOT NULL, created_by varchar(128) NOT NULL, updated_at timestamptz NOT NULL, updated_by varchar(128) NOT NULL, version bigint NOT NULL DEFAULT 0, CONSTRAINT production__work_order_input_qty_pos CHECK (quantity_per_unit > 0), CONSTRAINT production__work_order_input_line_no_pos CHECK (line_no > 0), CONSTRAINT production__work_order_input_line_uk UNIQUE (work_order_id, line_no) ); CREATE INDEX production__work_order_input_wo_idx ON production__work_order_input (work_order_id); CREATE INDEX production__work_order_input_item_idx ON production__work_order_input (item_code); DROP TABLE production__work_order_input;