From bfe73050e3351ffe76ef714185c3a456b0c22c51 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 5 Jun 2024 16:57:59 +0100 Subject: [PATCH] Bug 36453: (QA follow-up) Modernise database update This patch adds the colored output expected for 24.11.x onward database updates. Signed-off-by: Martin Renvoize --- .../data/mysql/atomicupdate/bug_36453.pl | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_36453.pl b/installer/data/mysql/atomicupdate/bug_36453.pl index 08d6734d15..d267ca250e 100755 --- a/installer/data/mysql/atomicupdate/bug_36453.pl +++ b/installer/data/mysql/atomicupdate/bug_36453.pl @@ -1,4 +1,5 @@ use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); return { bug_number => "36453", @@ -7,6 +8,10 @@ return { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; + # Update system preference setting to multiple instead of YesNo + $dbh->do("UPDATE systempreferences SET type='multiple' WHERE variable='BlockExpiredPatronOpacActions'") == 1 + and say_success( $out, "BlockExpiredPatronOpacActions system preference type updated to multiple." ); + my ($BlockExpiredPatronOpacActions) = $dbh->selectrow_array( q{ SELECT value FROM systempreferences WHERE variable = 'BlockExpiredPatronOpacActions'; @@ -18,42 +23,44 @@ return { # Update system preference settings if 1 $dbh->do( "UPDATE systempreferences SET value='hold,renew' WHERE variable='BlockExpiredPatronOpacActions' and value=1" - ); - say $out "BlockExpiredPatronOpacActions system preference value updated to 'hold,renew'."; + ) == 1 + and say_info( $out, "BlockExpiredPatronOpacActions system preference value updated to 'hold,renew'." ); } elsif ( $BlockExpiredPatronOpacActions eq 0 ) { # Update system preference settings if 0 - $dbh->do( - "UPDATE systempreferences SET value='' WHERE variable='BlockExpiredPatronOpacActions' and value=0"); - say $out "BlockExpiredPatronOpacActions system preference value updated to empty string."; + $dbh->do("UPDATE systempreferences SET value='' WHERE variable='BlockExpiredPatronOpacActions' and value=0") + == 1 + and + say_info( $out, "BlockExpiredPatronOpacActions system preference value updated to an empty string." ); } - # Update system preference setting to multiple instead of YesNo - $dbh->do("UPDATE systempreferences SET type='multiple' WHERE variable='BlockExpiredPatronOpacActions'"); - say $out "BlockExpiredPatronOpacActions system preference value updated to multiple."; - # Update categories database table BlockExpiredPatronOpacActions column settings $dbh->do( "ALTER TABLE categories MODIFY BlockExpiredPatronOpacActions mediumtext NOT NULL DEFAULT 'follow_syspref_BlockExpiredPatronOpacActions' COMMENT 'specific actions expired patrons of this category are blocked from performing or if the BlockExpiredPatronOpacActions system preference is to be followed'" - ); - say $out "categories column BlockExpiredPatronOpacActions updated."; + ) and say_success( $out, "Updated categories.BlockExpiredPatronOpacActions to mediumtext" ); # Update patron categories using -1 $dbh->do( "UPDATE categories SET BlockExpiredPatronOpacActions = 'follow_syspref_BlockExpiredPatronOpacActions' WHERE BlockExpiredPatronOpacActions = '-1'" - ); - say $out - "Patron categories BlockExpiredPatronOpacActions = -1 have been updated to follow the syspref BlockExpiredPatronOpacActions."; + ) >= 1 + and say_info( + $out, + "Patron categories BlockExpiredPatronOpacActions = -1 have been updated to follow the syspref BlockExpiredPatronOpacActions." + ); # Update patron categories using 0 - $dbh->do("UPDATE categories SET BlockExpiredPatronOpacActions = '' WHERE BlockExpiredPatronOpacActions = '0'"); - say $out "Patron categories BlockExpiredPatronOpacActions = 0 have been updated to an empty string ('')."; + $dbh->do("UPDATE categories SET BlockExpiredPatronOpacActions = '' WHERE BlockExpiredPatronOpacActions = '0'") + >= 1 + and say_info( + $out, + "Patron categories BlockExpiredPatronOpacActions = 0 have been updated to an empty string ('')." + ); # Update patron categories using 1 $dbh->do( "UPDATE categories SET BlockExpiredPatronOpacActions = 'hold,renew' WHERE BlockExpiredPatronOpacActions = '1' " - ); - say $out "Patron categories BlockExpiredPatronOpacActions = 1 have been updated to hold,renew'."; - + ) >= 1 + and + say_info( $out, "Patron categories BlockExpiredPatronOpacActions = 1 have been updated to hold,renew'." ); }, }; -- 2.39.5