From 0423d09e57f6a64656dc0f82a10c82962960e049 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Thu, 12 Nov 2020 13:38:49 +0000 Subject: [PATCH] Bug 24083: (QA follow-up) Fix DB upgrade This commit makes the addition of the 'unseen_renewals_allowed' circulation rule idempotent, as highlighted by Jonathan in comment #140 Bug 24083: (QA follow-up) Fix for previous It helps if you don't commit commented out code... Signed-off-by: Jonathan Druart --- installer/data/mysql/updatedatabase.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 2133c7d2fb..2cd4b47fb3 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -23388,10 +23388,19 @@ if( CheckVersion( $DBversion ) ) { $DBversion = '20.06.00.069'; if( CheckVersion( $DBversion ) ) { - $dbh->do( q| - INSERT IGNORE INTO circulation_rules (rule_name, rule_value) - VALUES ('unseen_renewals_allowed', '') - | ); + my ($count) = $dbh->selectrow_array( + q| + SELECT COUNT(*) + FROM circulation_rules + WHERE rule_name = 'unseen_renewals_allowed' + | + ); + if ($count == 0) { + $dbh->do( q| + INSERT INTO circulation_rules (rule_name, rule_value) + VALUES ('unseen_renewals_allowed', '') + | ); + } if( !column_exists( 'issues', 'unseen_renewals' ) ) { $dbh->do( q| ALTER TABLE issues ADD unseen_renewals TINYINT(4) DEFAULT 0 NOT NULL AFTER renewals | ); -- 2.39.5