From 31b0c918d2055a958f8325c1bfa8ca981dd1dd6f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 13 May 2019 20:08:06 +0000 Subject: [PATCH] Bug 22899: Database update Signed-off-by: Martin Renvoize --- ...22899_add_items_constraint_to_tmpholdsqueue.perl | 13 +++++++++++++ installer/data/mysql/kohastructure.sql | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22899_add_items_constraint_to_tmpholdsqueue.perl diff --git a/installer/data/mysql/atomicupdate/bug_22899_add_items_constraint_to_tmpholdsqueue.perl b/installer/data/mysql/atomicupdate/bug_22899_add_items_constraint_to_tmpholdsqueue.perl new file mode 100644 index 0000000000..1e14394955 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22899_add_items_constraint_to_tmpholdsqueue.perl @@ -0,0 +1,13 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + # you can use $dbh here like: + unless ( foreign_key_exists( 'tmp_holdsqueue', 'tmp_holdsqueue_ibfk_1' ) ) { + $dbh->do(q{ + ALTER TABLE tmp_holdsqueue + ADD CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`) + REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE + }); + } + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - Add items constraint to tmp_holdsqueue)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index d5864d18d5..da3ff83f37 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2458,7 +2458,9 @@ CREATE TABLE `tmp_holdsqueue` ( `holdingbranch` varchar(10) default NULL, `pickbranch` varchar(10) default NULL, `notes` MEDIUMTEXT, - `item_level_request` tinyint(4) NOT NULL default 0 + `item_level_request` tinyint(4) NOT NULL default 0, + CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`) + REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.20.1