From 6c76399c42ef5c6124f5119a63a8c2f86c70b95a Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 17 Sep 2021 08:38:44 +0000 Subject: [PATCH] Bug 27947: (follow-up) Improve atomic update We do not need to replace the whole notice text, we only need to replace the reference to article_requests.notes. Test plan: Run the dbrev. Verify result for notice AR_CANCELED. Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- installer/data/mysql/atomicupdate/bug_27947.pl | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_27947.pl b/installer/data/mysql/atomicupdate/bug_27947.pl index c1f300991d..3905db87f0 100755 --- a/installer/data/mysql/atomicupdate/bug_27947.pl +++ b/installer/data/mysql/atomicupdate/bug_27947.pl @@ -6,36 +6,29 @@ return { up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out column_exists)}; - # Do you stuffs here $dbh->do(q{ INSERT IGNORE INTO authorised_value_categories( category_name, is_system ) VALUES ('AR_CANCELLATION', 0) }); - # Print useful stuff here say $out "Add AR_CANCELLATION category for authorised values"; $dbh->do(q{ INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','NOT_FOUND','Item could not be located on shelves'); }); - $dbh->do(q{ INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES ('AR_CANCELLATION','DAMAGED','Item was found to be too damaged to fill article request'); }); - say $out "Add AR_CANCELLATION authorised values"; $dbh->do(q{ ALTER TABLE `article_requests` ADD COLUMN `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value AR_CANCELLATION' AFTER `urls` }) unless column_exists('article_requests', 'cancellation_reason'); - - # Print useful stuff here say $out "Add cancellation_reason column in article_requests table"; $dbh->do(q{ - UPDATE `letter` - SET `content` = 'Dear <> <> (<>),\r\n\r\nYour request for an article from <> (<>) has been canceled for the following reason:\r\n\r\n<>\r\n\r\nArticle requested:\r\nTitle: <>\r\nAuthor: <>\r\nVolume: <>\r\nIssue: <>\r\nDate: <>\r\nPages: <>\r\nChapters: <>\r\nNotes: <>\r\nFormat: [% IF article_request.format == ''PHOTOCOPY'' %]Copy[% ELSIF article_request.format == ''SCAN'' %]Scan[% END %]\r\n\r\nYour library' - WHERE `module` = 'circulation' - AND `code` = 'AR_CANCELED' - }) + UPDATE letter SET content=REPLACE(content, '<>', '<>') + WHERE module = 'circulation' AND code = 'AR_CANCELED' + }); + say $out "Replace notes by reason in notice AR_CANCELED"; }, -} \ No newline at end of file +} -- 2.39.5