Try making it:
PRIMARY KEY (`parent`,`loc_code`,`component`,`workcentre_added`),
KEY `component` (`component`),
KEY `id` (`id`),
KEY `loc_code` (`loc_code`),
KEY `workcentre_added` (`workcentre_added`)
to remove redundant indices but that is not the fix.
The fields parent and component refer to stock_id which is varchar(20) in the other tables and hence these two should be varchar(20) too but that should not generally be the cause of any problems except for type matching and index based joins.
The following sql will achieve the above changes:
ALTER TABLE `0_bom`
CHANGE `parent` `parent` VARCHAR(20) DEFAULT '' NOT NULL,
CHANGE `component` `component` VARCHAR(20) DEFAULT '' NOT NULL,
DROP INDEX `parent`,
DROP PRIMARY KEY, ADD PRIMARY KEY (`parent`, `loc_code`, `component`, `workcentre_added`);
The file / function that is in error is:
includes/db/manufacturing_db.inc => update_bom()
function update_bom($selected_parent, $selected_component, $workcentre_added, $loc_code, $quantity)
{
$sql = "UPDATE ".TB_PREF."bom SET workcentre_added=".db_escape($workcentre_added)
. ",loc_code=".db_escape($loc_code) . ",
quantity= " . $quantity . "
WHERE parent=".db_escape($selected_parent) . "
AND id=".db_escape($selected_component);
check_db_error("Could not update this bom component", $sql);
db_query($sql,"could not update bom");
}
should be
function update_bom($selected_parent, $selected_component, $workcentre_added, $loc_code, $quantity)
{
$sql = "UPDATE ".TB_PREF."bom SET workcentre_added=".db_escape($workcentre_added)
. ",loc_code=".db_escape($loc_code) . ",
quantity= " . $quantity . "
WHERE parent=".db_escape($selected_parent) . "
AND component=".db_escape($selected_component);
check_db_error("Could not update this bom component", $sql);
db_query($sql,"could not update bom");
}
The only two functions there that use the id field in the 0_bom table are:
delete_bom()
get_component_from_bom()
*** The fix listed above for the file manufacturing_db.inc is not correct ***
It has been superceeded by a later commit in my GitHub Repo. - Thanks @itronics for pointing me in the right direction.