From 6259d3933d4c3025792cfd57af5312385394bc5a Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 15 May 2017 11:41:48 +0000 Subject: [PATCH] Bug 18606: Database changes - Add foreign keys to collections_tracking --- installer/data/mysql/atomicupdate/rotatingCollections.perl | 7 +++++++ installer/data/mysql/kohastructure.sql | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/rotatingCollections.perl diff --git a/installer/data/mysql/atomicupdate/rotatingCollections.perl b/installer/data/mysql/atomicupdate/rotatingCollections.perl new file mode 100644 index 0000000..24c2324 --- /dev/null +++ b/installer/data/mysql/atomicupdate/rotatingCollections.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; # will be replaced by RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "ALTER TABLE collections_tracking ADD CONSTRAINT collections_tracking_ibfk_1 FOREIGN KEY (colId) REFERENCES collections (colId) ON DELETE CASCADE ON UPDATE CASCADE" ); $dbh->do( "ALTER TABLE collections_tracking ADD CONSTRAINT collections_tracking_ibfk_2 FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE" ); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - Rotating collections objects)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 2edd371..1ef5a98 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -368,6 +368,12 @@ CREATE TABLE collections_tracking ( PRIMARY KEY (collections_tracking_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +ALTER TABLE `collections_tracking` + ADD CONSTRAINT `collections_tracking_ibfk_1` FOREIGN KEY (`colId`) REFERENCES `collections` (`colId`) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `collections_tracking` + ADD CONSTRAINT `collections_tracking_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE; + -- -- Table structure for table `branch_borrower_circ_rules` -- -- 2.1.4