summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-27 18:36:46 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-27 18:36:46 +0100
commit0600dff4d66012faf6bd51996ce1cc868eb456f4 (patch)
tree6b245b0720edff3184235ff7f9683f7defe2a902 /admin
parente9dfcb6700ba7f76ed4cfcd71ac2fda8ddb01151 (diff)
downloadstock-0600dff4d66012faf6bd51996ce1cc868eb456f4.tar.gz
stock-0600dff4d66012faf6bd51996ce1cc868eb456f4.tar.bz2
stock-0600dff4d66012faf6bd51996ce1cc868eb456f4.zip
Add composite PRIMARY KEY to both junction tables
stock_assembly_component_map and stock_movement_item gain proper composite PKs on their two content_id columns. PRIMARY implies NOT NULL so the redundant NOTNULL qualifiers are dropped. Individual indexes on those columns are removed as the PK covers them. Live DB: ALTER TABLE ... ADD PRIMARY KEY; DROP INDEX x4 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'admin')
-rwxr-xr-xadmin/schema_inc.php12
1 files changed, 4 insertions, 8 deletions
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index c11455c..08d09df 100755
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -12,8 +12,8 @@ $tables = [
",
'stock_assembly_component_map' => "
- assembly_content_id I4 NOTNULL,
- item_content_id I4 NOTNULL,
+ assembly_content_id I4 PRIMARY,
+ item_content_id I4 PRIMARY,
item_position N(10,3),
quantity_value N(10,3) DEFAULT 1,
quantity_item C(8) DEFAULT 'SGL'
@@ -33,8 +33,8 @@ $tables = [
",
'stock_movement_item' => "
- movement_content_id I4 NOTNULL,
- item_content_id I4 NOTNULL,
+ movement_content_id I4 PRIMARY,
+ item_content_id I4 PRIMARY,
item_position N(10,3),
quantity_value N(10,3) DEFAULT 1,
quantity_item C(8) DEFAULT 'SGL'
@@ -51,14 +51,10 @@ foreach( array_keys( $tables ) AS $tableName ) {
$indices = [
'stock_assembly_id_idx' => [ 'table' => 'stock_assembly', 'cols' => 'assembly_id', 'opts' => null ],
'stock_assembly_content_idx' => [ 'table' => 'stock_assembly', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ],
- 'stock_map_assembly_idx' => [ 'table' => 'stock_assembly_component_map', 'cols' => 'assembly_content_id', 'opts' => null ],
- 'stock_map_item_idx' => [ 'table' => 'stock_assembly_component_map', 'cols' => 'item_content_id', 'opts' => null ],
'stock_component_id_idx' => [ 'table' => 'stock_component', 'cols' => 'component_id', 'opts' => null ],
'stock_component_content_idx' => [ 'table' => 'stock_component', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ],
'stock_movement_content_idx' => [ 'table' => 'stock_movement', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ],
'stock_movement_parent_idx' => [ 'table' => 'stock_movement', 'cols' => 'parent_id', 'opts' => null ],
- 'stock_movement_item_movement_idx' => [ 'table' => 'stock_movement_item', 'cols' => 'movement_content_id', 'opts' => null ],
- 'stock_movement_item_item_idx' => [ 'table' => 'stock_movement_item', 'cols' => 'item_content_id', 'opts' => null ],
];
$gBitInstaller->registerSchemaIndexes( STOCK_PKG_NAME, $indices );