From ca3a4727329780291a59a3f2ae530da25a2f0756 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 --- .../mysql/atomicupdate/rotatingCollections.perl | 7 +++++ installer/data/mysql/kohastructure.sql | 30 +++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) 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 8151a29..2704642 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -328,18 +328,6 @@ ALTER TABLE `collections` ADD CONSTRAINT `collections_ibfk_1` FOREIGN KEY (`colBranchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE; -- --- Table: collections_tracking --- - -DROP TABLE IF EXISTS collections_tracking; -CREATE TABLE collections_tracking ( - collections_tracking_id integer(11) NOT NULL auto_increment, - colId integer(11) NOT NULL DEFAULT 0 comment 'collections.colId', - itemnumber integer(11) NOT NULL DEFAULT 0 comment 'items.itemnumber', - PRIMARY KEY (collections_tracking_id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - --- -- Table structure for table `branch_borrower_circ_rules` -- @@ -970,6 +958,24 @@ CREATE TABLE `itemtypes` ( -- defines the item types ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- +-- Table: collections_tracking +-- + +DROP TABLE IF EXISTS collections_tracking; +CREATE TABLE collections_tracking ( + collections_tracking_id integer(11) NOT NULL auto_increment, + colId integer(11) NOT NULL DEFAULT 0 comment 'collections.colId', + itemnumber integer(11) NOT NULL DEFAULT 0 comment 'items.itemnumber', + PRIMARY KEY (collections_tracking_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_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 `default_branch_item_rules` -- -- 2.1.4