From 2abb30d044df79d89d7afe62560961e5f0d08e5b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 6 Mar 2017 17:35:40 +0000 Subject: [PATCH] Bug 18887 - Update database --- installer/data/mysql/atomicupdate/bug_18887.perl | 41 ++++++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 21 ++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_18887.perl diff --git a/installer/data/mysql/atomicupdate/bug_18887.perl b/installer/data/mysql/atomicupdate/bug_18887.perl new file mode 100644 index 0000000000..38610c9d44 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_18887.perl @@ -0,0 +1,41 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + $dbh->do(q{ + CREATE TABLE `circulation_rules` ( + `id` int(11) NOT NULL auto_increment, + `branchcode` varchar(10) NULL default NULL, + `categorycode` varchar(10) NULL default NULL, + `itemtype` varchar(10) NULL default NULL, + `rule_name` varchar(32) NOT NULL, + `rule_value` varchar(32) NOT NULL, + PRIMARY KEY (`id`), + KEY `branchcode` (`branchcode`), + KEY `categorycode` (`categorycode`), + KEY `itemtype` (`itemtype`), + KEY `rule_name` (`rule_name`), + UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + }); + + $dbh->do(q{ + INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) + SELECT branchcode, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules + }); + + $dbh->do(q{ + INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) + SELECT NULL, categorycode, NULL, 'max_holds', max_holds FROM branch_borrower_circ_rules + }); + + $dbh->do(q{ + ALTER TABLE branch_borrower_circ_rules DROP COLUMN max_holds + }); + + $dbh->do(q{ + ALTER TABLE default_borrower_circ_rules DROP COLUMN max_holds + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 18887 - Introduce new table 'circulation_rules', use for 'max_holds' rules)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 1fe993619e..48509f48e8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -379,7 +379,6 @@ CREATE TABLE `branch_borrower_circ_rules` ( -- includes default circulation rule `categorycode` VARCHAR(10) NOT NULL, -- the patron category this rule applies to (categories.categorycode) `maxissueqty` int(4) default NULL, -- the maximum number of checkouts this patron category can have at this branch `maxonsiteissueqty` int(4) default NULL, -- the maximum number of on-site checkouts this patron category can have at this branch - max_holds INT(4) NULL DEFAULT NULL, -- the maximum number of holds a patron may have at a time PRIMARY KEY (`categorycode`, `branchcode`), CONSTRAINT `branch_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -396,7 +395,6 @@ CREATE TABLE `default_borrower_circ_rules` ( -- default checkout rules found und `categorycode` VARCHAR(10) NOT NULL, -- patron category this rul `maxissueqty` int(4) default NULL, `maxonsiteissueqty` int(4) default NULL, - max_holds INT(4) NULL DEFAULT NULL, -- the maximum number of holds a patron may have at a time PRIMARY KEY (`categorycode`), CONSTRAINT `borrower_borrower_circ_rules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE @@ -4164,6 +4162,25 @@ CREATE TABLE illrequestattributes ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +-- +-- Table structure for table `circulation_rules` +-- + +DROP TABLE IF EXISTS `circulation_rules`; +CREATE TABLE `circulation_rules` ( + `id` int(11) NOT NULL auto_increment, + `branchcode` varchar(10) NULL default NULL, + `categorycode` varchar(10) NULL default NULL, + `itemtype` varchar(10) NULL default NULL, + `rule_name` varchar(32) NOT NULL, + `rule_value` varchar(32) NOT NULL, + PRIMARY KEY (`id`), + KEY `branchcode` (`branchcode`), + KEY `categorycode` (`categorycode`), + KEY `itemtype` (`itemtype`), + UNIQUE (`branchcode`,`categorycode`,`itemtype`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -- 2.15.1