Bugzilla – Attachment 125158 Details for
Bug 27944
Add new stages to the article request process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27944: (QA follow-up) Make atomic update idempotent
Bug-27944-QA-follow-up-Make-atomic-update-idempote.patch (text/plain), 5.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-09-22 18:15:06 UTC
(
hide
)
Description:
Bug 27944: (QA follow-up) Make atomic update idempotent
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-09-22 18:15:06 UTC
Size:
5.27 KB
patch
obsolete
>From 7c6e7b83d5daf6384a85dc56d7ad37702224000b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 22 Sep 2021 14:42:28 -0300 >Subject: [PATCH] Bug 27944: (QA follow-up) Make atomic update idempotent > >This patch checks the DB structure to see if the status column >definition contains 'REQUESTED' as a valid ENUM value. > >The script is also moved into the new style. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../data/mysql/atomicupdate/1_bug_27944.pl | 40 +++++++++++++++++++ > .../data/mysql/atomicupdate/bug_27944.perl | 31 -------------- > 2 files changed, 40 insertions(+), 31 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/1_bug_27944.pl > delete mode 100644 installer/data/mysql/atomicupdate/bug_27944.perl > >diff --git a/installer/data/mysql/atomicupdate/1_bug_27944.pl b/installer/data/mysql/atomicupdate/1_bug_27944.pl >new file mode 100755 >index 0000000000..49507c0e9d >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/1_bug_27944.pl >@@ -0,0 +1,40 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "27944", >+ description => "Add REQUESTED as enum element for status column, move AR_PENDING letter to AR_REQUESTED, and add new AR_PENDING letter", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh) = @$args{qw(dbh)}; >+ >+ # check if we already added the REQUESTED type in ENUM >+ my @row = $dbh->selectrow_array(q{ >+ SHOW COLUMNS FROM article_requests WHERE Field='status' AND Type LIKE "%'REQUESTED'%"; >+ }); >+ >+ unless (@row) { >+ $dbh->do(q{ >+ ALTER TABLE `article_requests` >+ MODIFY `status` enum('REQUESTED', 'PENDING','PROCESSING','COMPLETED','CANCELED') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'REQUESTED' >+ }); >+ $dbh->do(q{ >+ UPDATE article_requests >+ SET status='REQUESTED' WHERE status='PENDING' >+ }); >+ >+ $dbh->do(q{ >+ UPDATE `letter` >+ SET `code` = 'AR_REQUESTED', >+ `name` = REPLACE(name, '- open', '- new') >+ WHERE `module` = 'circulation' >+ AND `code` = 'AR_PENDING' >+ }) >+ if ( $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE code=?', undef, 'AR_REQUESTED') )[0] == 0; # Check to make idempotent >+ >+ $dbh->do(q{ >+ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES >+ ('circulation', 'AR_PENDING', '', 'Article request - pending', 0, 'Pending article request', 'Dear <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nYour request for an article from <<biblio.title>> (<<items.barcode>>) is now in pending state.\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n\r\n\r\nThank you!', 'email') >+ }); >+ } >+ }, >+} >diff --git a/installer/data/mysql/atomicupdate/bug_27944.perl b/installer/data/mysql/atomicupdate/bug_27944.perl >deleted file mode 100644 >index 1d0f2f2b0a..0000000000 >--- a/installer/data/mysql/atomicupdate/bug_27944.perl >+++ /dev/null >@@ -1,31 +0,0 @@ >-$DBversion = 'XXX'; # will be replaced by the RM >-if ( CheckVersion($DBversion) ) { >- >- # you can use $dbh here like: >- $dbh->do( >-"ALTER TABLE `article_requests` MODIFY `status` enum('REQUESTED', 'PENDING','PROCESSING','COMPLETED','CANCELED') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'REQUESTED'" >- ); >- $dbh->do(q|UPDATE article_requests SET status='REQUESTED' WHERE status='PENDING'|); >- >- $dbh->do( >- q{ >- UPDATE `letter` >- SET `code` = 'AR_REQUESTED', >- `name` = REPLACE(name, '- open', '- new') >- WHERE `module` = 'circulation' >- AND `code` = 'AR_PENDING' >- } >- ) if ( $dbh->selectrow_array('SELECT COUNT(*) FROM letter WHERE code=?', undef, 'AR_REQUESTED') )[0] == 0; # Check to make idempotent >- >- $dbh->do( >- q{ >- INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES >- ('circulation', 'AR_PENDING', '', 'Article request - pending', 0, 'Pending article request', 'Dear <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>)\r\n\r\nYour request for an article from <<biblio.title>> (<<items.barcode>>) is now in pending state.\r\n\r\nArticle requested:\r\nTitle: <<article_requests.title>>\r\nAuthor: <<article_requests.author>>\r\nVolume: <<article_requests.volume>>\r\nIssue: <<article_requests.issue>>\r\nDate: <<article_requests.date>>\r\nPages: <<article_requests.pages>>\r\nChapters: <<article_requests.chapters>>\r\nNotes: <<article_requests.patron_notes>>\r\n\r\n\r\nThank you!', 'email') >- } >- ); >- >- # Always end with this (adjust the bug info) >- NewVersion( $DBversion, 27944, >-"Add REQUESTED as enum element for status column, move AR_PENDING letter to AR_REQUESTED, and add new AR_PENDING letter" >- ); >-} >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27944
:
119020
|
119021
|
119022
|
120454
|
122673
|
122836
|
122837
|
122838
|
122839
|
122842
|
122843
|
122857
|
122984
|
122985
|
122986
|
122987
|
122988
|
122989
|
122990
|
123710
|
123711
|
123712
|
123943
|
123944
|
123945
|
123946
|
123947
|
123948
|
123949
|
123950
|
123951
|
123952
|
124966
|
124967
|
124968
|
124969
|
124970
|
124971
|
124972
|
124973
|
124974
|
124975
|
124976
| 125158 |
125544
|
125565
|
125567
|
125762
|
125813