From 5ec37d89a6f6f988448abd2a43ce23d812d46380 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 15 Oct 2021 15:02:50 +0000 Subject: [PATCH] Bug 28153: (follow-up) Add installer files and update atomicupdate Signed-off-by: Jonathan Druart --- ...53_add_holdreminder_notice_preference.perl | 16 ------- ...8153_add_holdreminder_notice_preference.pl | 44 +++++++++++++++++++ .../sample_notices_message_attributes.sql | 1 + .../sample_notices_message_transports.sql | 4 ++ 4 files changed, 49 insertions(+), 16 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.perl create mode 100644 installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.pl diff --git a/installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.perl b/installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.perl deleted file mode 100644 index 8fd4aa7cf8..0000000000 --- a/installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.perl +++ /dev/null @@ -1,16 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - INSERT IGNORE INTO `message_attributes` - (`message_attribute_id`, message_name, `takes_days`) - VALUES (10, 'Hold_Reminder', 0) - }); - $dbh->do( q{ - INSERT IGNORE INTO `message_transports` - (`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`) - VALUES (10, 'email', 0, 'circulation', 'HOLD_REMINDER'), - (10, 'sms', 0, 'circulation', 'HOLD_REMINDER'), - (10, 'phone', 0, 'circulation', 'HOLD_REMINDER') - }); - NewVersion( $DBversion, 28153, "Add Hold reminder messaging preference"); -} diff --git a/installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.pl b/installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.pl new file mode 100644 index 0000000000..2f7c1192a6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28153_add_holdreminder_notice_preference.pl @@ -0,0 +1,44 @@ +use Modern::Perl; + +return { + bug_number => "28153", + description => "Add Hold Reminder messaging preference", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + INSERT IGNORE INTO `message_attributes` + (message_attribute_id, message_name, `takes_days`) + VALUES (10, 'Hold_Reminder', 0) + }); + say $out "Message attribute added"; + $dbh->do(q{ + INSERT IGNORE INTO `message_transports` + (`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`) + VALUES (10, 'email', 0, 'circulation', 'HOLD_REMINDER'), + (10, 'sms', 0, 'circulation', 'HOLD_REMINDER'), + (10, 'phone', 0, 'circulation', 'HOLD_REMINDER'), + (10, 'itiva', 0, 'circulation', 'HOLD_REMINDER') + }); + say $out "HOLD_REMINDER added to message_transports"; + $dbh->do(q{ + INSERT INTO borrower_message_preferences + ( borrowernumber, categorycode, message_attribute_id, days_in_advance, wants_digest ) + SELECT borrowernumber, categorycode, 10, days_in_advance, wants_digest + FROM borrower_message_preferences WHERE message_attribute_id = 4 + }); + say $out "Hold_Filled message preference copied to Hold_Reminder"; + $dbh->do(q{ + INSERT INTO borrower_message_transport_preferences + ( borrower_message_preference_id, message_transport_type ) + SELECT b1.borrower_message_preference_id, message_transport_type + FROM borrower_message_preferences b1 + JOIN borrower_message_preferences b2 ON + b1.message_attribute_id = 10 AND b2.message_attribute_id = 4 AND + b1.borrowernumber=b2.borrowernumber + JOIN borrower_message_transport_preferences bt ON + b2.borrower_message_preference_id = bt.borrower_message_preference_id + }); + say $out "Hold_Filled message transport preferences copied to Hold_Reminder"; + }, +} diff --git a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql index d32f2d1b54..7cfff1c157 100644 --- a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql +++ b/installer/data/mysql/mandatory/sample_notices_message_attributes.sql @@ -9,4 +9,5 @@ values (7, 'Ill_ready', 0), (8, 'Ill_unavailable', 0), (9, 'Auto_Renewals', 0); +(10, 'Hold_Reminder', 0); diff --git a/installer/data/mysql/mandatory/sample_notices_message_transports.sql b/installer/data/mysql/mandatory/sample_notices_message_transports.sql index ac4bcd5629..b2f85657a2 100644 --- a/installer/data/mysql/mandatory/sample_notices_message_transports.sql +++ b/installer/data/mysql/mandatory/sample_notices_message_transports.sql @@ -35,3 +35,7 @@ values (9, 'sms', 0, 'circulation', 'AUTO_RENEWALS'), (9, 'email', 1, 'circulation', 'AUTO_RENEWALS_DGST'), (9, 'sms', 1, 'circulation', 'AUTO_RENEWALS_DGST'); +(10, 'email', 0, 'circulation', 'HOLD_REMINDER'), +(10, 'sms', 0, 'circulation', 'HOLD_REMINDER'), +(10, 'phone', 0, 'circulation', 'HOLD_REMINDER'), +(10, 'itiva', 0, 'circulation', 'HOLD_REMINDER'), -- 2.39.5