From 13faff1250ed3ede712c405821f3ad9187e892b6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 2 Mar 2019 13:45:14 -0300 Subject: [PATCH] Bug 18925: Move existing rules Signed-off-by: Tomas Cohen Arazi Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- .../data/mysql/atomicupdate/bug_18925.perl | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_18925.perl b/installer/data/mysql/atomicupdate/bug_18925.perl index 89d943f597..810901b026 100644 --- a/installer/data/mysql/atomicupdate/bug_18925.perl +++ b/installer/data/mysql/atomicupdate/bug_18925.perl @@ -60,6 +60,28 @@ if( CheckVersion( $DBversion ) ) { $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); } + if ( column_exists( 'issuingrules', 'maxissueqty' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT IF(categorycode='*', NULL, categorycode), + IF(branchcode='*', NULL, branchcode), + IF(itemtype='*', NULL, itemtype), + 'maxissueqty', + COALESCE( maxissueqty, '' ) + FROM issuingrules + "); + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT IF(categorycode='*', NULL, categorycode), + IF(branchcode='*', NULL, branchcode), + IF(itemtype='*', NULL, itemtype), + 'maxonsiteissueqty', + COALESCE( maxonsiteissueqty, '' ) + FROM issuingrules + "); + $dbh->do("ALTER TABLE issuingrules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); + } + SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n"; }