From 5048c5768095fbd7574dd63fa974e0de54251c87 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Jun 2018 12:57:09 -0300 Subject: [PATCH] Bug 15836: DB changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian Stelzenmüller Signed-off-by: Chris Cormack --- .../data/mysql/atomicupdate/bug_15836.perl | 42 +++++++++++++++++++ .../data/mysql/en/mandatory/class_sources.sql | 19 +++++---- installer/data/mysql/kohastructure.sql | 21 +++++++++- 3 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15836.perl diff --git a/installer/data/mysql/atomicupdate/bug_15836.perl b/installer/data/mysql/atomicupdate/bug_15836.perl new file mode 100644 index 0000000000..069b7503f8 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15836.perl @@ -0,0 +1,42 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( TableExists( 'class_split_rules' ) ) { + $dbh->do(q| + CREATE TABLE class_split_rules ( + class_split_rule varchar(10) NOT NULL default '', + description LONGTEXT, + split_routine varchar(30) NOT NULL default '', + split_regex varchar(255) NOT NULL default '', + PRIMARY KEY (class_split_rule), + UNIQUE KEY class_split_rule_idx (class_split_rule) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + |); + + $dbh->do(q| + ALTER TABLE class_sources + ADD COLUMN class_split_rule varchar(10) NOT NULL default '' + AFTER class_sort_rule + |); + $dbh->do(q| + UPDATE class_sources + SET class_split_rule = class_sort_rule + |); + + $dbh->do(q| + INSERT INTO class_split_rules(class_split_rule, description, split_routine) + VALUES + ('dewey', 'Default sorting rules for DDC', 'dewey'), + ('lcc', 'Default sorting rules for LCC', 'LCC'), + ('generic', 'Generic call number sorting rules', 'Generic') + |); + + $dbh->do(q| + ALTER TABLE class_sources + ADD CONSTRAINT class_source_ibfk_2 FOREIGN KEY (class_split_rule) + REFERENCES class_split_rules (class_split_rule) + |); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 15836 - Add class_sort_rules.split_routine and split_regex)\n"; +} diff --git a/installer/data/mysql/en/mandatory/class_sources.sql b/installer/data/mysql/en/mandatory/class_sources.sql index 589ea7a689..735ef28583 100644 --- a/installer/data/mysql/en/mandatory/class_sources.sql +++ b/installer/data/mysql/en/mandatory/class_sources.sql @@ -3,6 +3,7 @@ -- for Koha. -- -- Copyright (C) 2007 LiblimeA +-- Copyright 2018 Koha Development Team -- -- This file is part of Koha. -- @@ -25,12 +26,16 @@ INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine` ('lcc', 'Default filing rules for LCC', 'LCC'), ('generic', 'Generic call number filing rules', 'Generic'); +INSERT INTO `class_split_rules` (`class_split_rule`, `description`, `split_routine`) VALUES + ('dewey', 'Default splitting rules for DDC', 'Dewey'), + ('lcc', 'Default splitting rules for LCC', 'LCC'), + ('generic', 'Generic call number splitting rules', 'Generic'); -- classification schemes or sources -INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES - ('ddc', 'Dewey Decimal Classification', 1, 'dewey'), - ('lcc', 'Library of Congress Classification', 1, 'lcc'), - ('udc', 'Universal Decimal Classification', 0, 'generic'), - ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'), - ('anscr', 'ANSCR (Sound Recordings)', 0, 'generic'), - ('z', 'Other/Generic Classification Scheme', 0, 'generic'); +INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`, `class_split_rule`) VALUES + ('ddc', 'Dewey Decimal Classification', 1, 'dewey', 'dewey'), + ('lcc', 'Library of Congress Classification', 1, 'lcc', 'lcc'), + ('udc', 'Universal Decimal Classification', 0, 'generic', 'generic'), + ('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic', 'generic'), + ('anscr', 'ANSCR (Sound Recordings)', 0, 'generic', 'generic'), + ('z', 'Other/Generic Classification Scheme', 0, 'generic', 'generic'); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 46e4459e89..e3f919fec6 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -438,10 +438,27 @@ CREATE TABLE `class_sort_rules` ( `class_sort_rule` varchar(10) NOT NULL default '', `description` LONGTEXT, `sort_routine` varchar(30) NOT NULL default '', + `split_routine` varchar(30) NOT NULL default '', + `split_regex` varchar(255) NOT NULL default '', PRIMARY KEY (`class_sort_rule`), UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `class_split_rules` +-- + +DROP TABLE IF EXISTS `class_split_rules`; + +CREATE TABLE class_split_rules ( + class_split_rule varchar(10) NOT NULL default '', + description LONGTEXT, + split_routine varchar(30) NOT NULL default '', + split_regex varchar(255) NOT NULL default '', + PRIMARY KEY (class_split_rule), + UNIQUE KEY class_split_rule_idx (class_split_rule) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `class_sources` -- @@ -452,10 +469,12 @@ CREATE TABLE `class_sources` ( `description` LONGTEXT, `used` tinyint(4) NOT NULL default 0, `class_sort_rule` varchar(10) NOT NULL default '', + `class_split_rule` varchar(10) NOT NULL default '', PRIMARY KEY (`cn_source`), UNIQUE KEY `cn_source_idx` (`cn_source`), KEY `used_idx` (`used`), - CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`) + CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`), + CONSTRAINT `class_source_ibfk_2` FOREIGN KEY (`class_split_rule`) REFERENCES `class_split_rules` (`class_split_rule`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.19.1