Bug 22899: Database update
authorNick Clemens <nick@bywatersolutions.com>
Mon, 13 May 2019 20:08:06 +0000 (20:08 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 14 May 2019 18:08:34 +0000 (18:08 +0000)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

installer/data/mysql/atomicupdate/bug_22899_add_items_constraint_to_tmpholdsqueue.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

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 (file)
index 0000000..1e14394
--- /dev/null
@@ -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";
+}
index d5864d1..da3ff83 100644 (file)
@@ -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;
 
 --