From afc44f3df1c658456c8eba15024ed34fa0da3ffa Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 4 Feb 2020 13:19:18 +0000 Subject: [PATCH] Bug 24338: (QA follow-up) Make update idempotent Signed-off-by: David Nind --- installer/data/mysql/atomicupdate/bug_24338.perl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_24338.perl b/installer/data/mysql/atomicupdate/bug_24338.perl index bf154169ae..b4483240f8 100644 --- a/installer/data/mysql/atomicupdate/bug_24338.perl +++ b/installer/data/mysql/atomicupdate/bug_24338.perl @@ -1,11 +1,18 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { - $dbh->do(qq{ - INSERT INTO - authorised_values (category,authorised_value,lib, lib_opac) - VALUES - ('PAYMENT_TYPE','CASH','Cash','Cash') - }); + my $exists; + eval { $exists = $dbh->do("SELECT 1 FROM authorised_values WHERE category = 'PAYMENT_TYPE' AND authorised_value = 'CASH'"); }; + if ( $exists == 0 ) { + print "Adding CASH payment type\n"; + $dbh->do(qq{ + INSERT INTO + authorised_values (category,authorised_value,lib, lib_opac) + VALUES + ('PAYMENT_TYPE','CASH','Cash','Cash') + }); + } else { + print "CASH payment type already found\n"; + } SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 24338 - Add 'CASH' to default 'PAYMENT_TYPE')\n"; -- 2.11.0