From ac19a513125412deedc6d17bbf965614553356b3 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Sun, 24 Mar 2019 22:50:42 -0300 Subject: [PATCH] Bug 22284: New ft_local_hold_group column, and 'holgroup' enum option In order to add groups for holds, this patch provides a new column in library_groups to identify them. Also provides new enum option for hold_fulfillment_policy column of default_branch_circ_rules, default_circ_rules, default_branch_item_rules and branch_item_rules. To test: 1) check that there is no ft_local_hold_group column in library_groups and that there are no 'holdgroup' enum option in hold_fulfillment_policy in default_branch_circ_rules, default_circ_rules, default_branch_item_rules and branch_item_rules 2) apply this patch 3) run perl installer/data/mysql/updatedatabase.pl SUCCESS => !(step 1) ;-D 4) Sign off Sponsored-by: VOKAL --- ...284_add_ft_local_hold_group_to_library_groups.perl | 19 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 11 ++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22284_add_ft_local_hold_group_to_library_groups.perl diff --git a/installer/data/mysql/atomicupdate/bug_22284_add_ft_local_hold_group_to_library_groups.perl b/installer/data/mysql/atomicupdate/bug_22284_add_ft_local_hold_group_to_library_groups.perl new file mode 100644 index 0000000000..98f6c3f17b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22284_add_ft_local_hold_group_to_library_groups.perl @@ -0,0 +1,19 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + # you can use $dbh here like: + # $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_staff" ); + + # or perform some test and warn + if( !column_exists( 'library_groups', 'ft_local_hold_group' ) ) { + $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_staff" ); + } + + $dbh->do("ALTER TABLE default_branch_circ_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'"); + $dbh->do("ALTER TABLE default_circ_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'"); + $dbh->do("ALTER TABLE default_branch_item_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'"); + $dbh->do("ALTER TABLE branch_item_rules MODIFY hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any'"); + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 22284 - Add ft_local_hold_group column to library_groups and alter hold_fulfillment_policy in rules tables)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 77224bcac3..9804b7f5a4 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -362,7 +362,7 @@ DROP TABLE IF EXISTS `default_branch_circ_rules`; CREATE TABLE `default_branch_circ_rules` ( `branchcode` VARCHAR(10) NOT NULL, `holdallowed` tinyint(1) default NULL, - hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode + hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode `returnbranch` varchar(15) default NULL, PRIMARY KEY (`branchcode`), CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) @@ -377,7 +377,7 @@ DROP TABLE IF EXISTS `default_circ_rules`; CREATE TABLE `default_circ_rules` ( `singleton` enum('singleton') NOT NULL default 'singleton', `holdallowed` int(1) default NULL, - hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode + hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode `returnbranch` varchar(15) default NULL, PRIMARY KEY (`singleton`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -977,7 +977,7 @@ DROP TABLE IF EXISTS `default_branch_item_rules`; CREATE TABLE `default_branch_item_rules` ( `itemtype` varchar(10) NOT NULL, `holdallowed` tinyint(1) default NULL, - hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode + hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode `returnbranch` varchar(15) default NULL, PRIMARY KEY (`itemtype`), CONSTRAINT `default_branch_item_rules_ibfk_1` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) @@ -1015,7 +1015,7 @@ CREATE TABLE `branch_item_rules` ( -- information entered in the circulation and `branchcode` varchar(10) NOT NULL, -- the branch this rule is for (branches.branchcode) `itemtype` varchar(10) NOT NULL, -- the item type this rule applies to (items.itype) `holdallowed` tinyint(1) default NULL, -- the number of holds allowed - hold_fulfillment_policy ENUM('any', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode + hold_fulfillment_policy ENUM('any', 'holdgroup', 'homebranch', 'holdingbranch') NOT NULL DEFAULT 'any', -- limit trapping of holds by branchcode `returnbranch` varchar(15) default NULL, -- the branch the item returns to (homebranch, holdingbranch, noreturn) PRIMARY KEY (`itemtype`,`branchcode`), KEY `branch_item_rules_ibfk_2` (`branchcode`), @@ -4204,7 +4204,8 @@ CREATE TABLE library_groups ( description MEDIUMTEXT NULL DEFAULT NULL, -- Longer explanation of the group, if necessary ft_hide_patron_info tinyint(1) NOT NULL DEFAULT 0, -- Turn on the feature "Hide patron's info" for this group ft_search_groups_opac tinyint(1) NOT NULL DEFAULT 0, -- Use this group for staff side search groups - ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0, -- Use this group for opac side search groups + ft_search_groups_staff tinyint(1) NOT NULL DEFAULT 0, -- Use this group for opac side search groups + ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0, -- Use this group to identify libraries as pick up location for holds created_on TIMESTAMP NULL, -- Date and time of creation updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- Date and time of last PRIMARY KEY id ( id ), -- 2.11.0