From fe9a0e3108dc6db02c3e0739b69b1bf656773901 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 16 Sep 2022 10:21:10 -0300 Subject: [PATCH] Bug 29144: (QA follow-up) Make update idempotent Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_29144.pl | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_29144.pl b/installer/data/mysql/atomicupdate/bug_29144.pl index 8d9ff107ba..0337bb51fe 100755 --- a/installer/data/mysql/atomicupdate/bug_29144.pl +++ b/installer/data/mysql/atomicupdate/bug_29144.pl @@ -1,19 +1,23 @@ use Modern::Perl; return { - bug_number => 29144, + bug_number => 29144, description => "Copy and remove branches.opac_info", up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - $dbh->do(q{ -INSERT IGNORE INTO additional_contents ( category,code,location,branchcode,title,content,lang,published_on ) -SELECT 'html_customizations', CONCAT('OpacLibraryInfo_', branches.branchcode), 'OpacLibraryInfo', branches.branchcode, branches.branchname, branches.opac_info, 'default', NOW() -FROM branches -WHERE branches.opac_info IS NOT NULL - }); - $dbh->do(q{ -ALTER TABLE branches DROP COLUMN opac_info; - }); + + if ( column_exists( 'branches', 'opac_info' ) ) { + $dbh->do(q{ + INSERT IGNORE INTO additional_contents ( category,code,location,branchcode,title,content,lang,published_on ) + SELECT 'html_customizations', CONCAT('OpacLibraryInfo_', branches.branchcode), 'OpacLibraryInfo', branches.branchcode, branches.branchname, branches.opac_info, 'default', NOW() + FROM branches + WHERE branches.opac_info IS NOT NULL + }); + + $dbh->do(q{ + ALTER TABLE branches DROP COLUMN opac_info; + }); + } }, }; -- 2.39.5