From 0949f69beb7df02aba39c6e72cade662def41f00 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 Signed-off-by: Lisette Scheer Signed-off-by: Jesse Maseto --- installer/data/mysql/atomicupdate/bug_18887.perl | 41 ++++++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 19 +++++++++++ 2 files changed, 60 insertions(+) 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 95c36175d2..c6b8022edf 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4208,6 +4208,25 @@ CREATE TABLE `oauth_access_tokens` ( PRIMARY KEY (`access_token`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_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.11.0