From 9259e836a9cb83021ec37a1291cc37d1b27e6bcc Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 6 Mar 2019 10:41:17 -0300 Subject: [PATCH] Bug 18930: (follow-up) Make DB update idempotent Signed-off-by: Tomas Cohen Arazi Signed-off-by: Agustin Moyano Signed-off-by: Josef Moravec --- installer/data/mysql/atomicupdate/bug_18930.perl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_18930.perl b/installer/data/mysql/atomicupdate/bug_18930.perl index 99533dec2d..92be5bd260 100644 --- a/installer/data/mysql/atomicupdate/bug_18930.perl +++ b/installer/data/mysql/atomicupdate/bug_18930.perl @@ -1,12 +1,15 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - if ( column_exists( 'refund_lost_item_fee_rules', 'refund' ) ) { - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT NULL, IF(branchcode='*', NULL, branchcode), NULL, 'refund', refund - FROM refund_lost_item_fee_rules - "); - $dbh->do("DROP TABLE refund_lost_item_fee_rules"); + + if ( TableExists('refund_lost_item_fee_rules') ) { + if ( column_exists( 'refund_lost_item_fee_rules', 'refund' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT NULL, IF(branchcode='*', NULL, branchcode), NULL, 'refund', refund + FROM refund_lost_item_fee_rules + "); + $dbh->do("DROP TABLE refund_lost_item_fee_rules"); + } } SetVersion( $DBversion ); -- 2.11.0