From c226f2c51bf4dc3bd78b6c2b8aeab50b07c1f748 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 24 Oct 2018 01:33:42 +0000
Subject: [PATCH] Bug 21639: Add phone transports to new and existing installs

To test:
1 - Confirm if you do or do not have 'phone' transports defined in the
message_transports table
2 - Apply patch
3 - Run updatedatabase
4 - If you didn't have them you should now
5 - Run updatedatabase again, confirm it doesn't error
6 - sudo koha-mysql kohadev
7 - DELETE from message_transports WHERE message_transport_type =
'phone'
8 - Run updatedatabase again
9 - Confirm the message transports table is restored
10 - Drop your DB (or reset_all in kohadevbox)
11 - Ensure the table is fully populated including phone notices
---
 .../mysql/atomicupdate/Bug_21639_add_phone_transports.perl  | 13 +++++++++++++
 .../en/mandatory/sample_notices_message_transports.sql      |  9 ++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 installer/data/mysql/atomicupdate/Bug_21639_add_phone_transports.perl

diff --git a/installer/data/mysql/atomicupdate/Bug_21639_add_phone_transports.perl b/installer/data/mysql/atomicupdate/Bug_21639_add_phone_transports.perl
new file mode 100644
index 0000000..1b5bf7d
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/Bug_21639_add_phone_transports.perl
@@ -0,0 +1,13 @@
+$DBversion = 'XXX';  # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q(
+        INSERT IGNORE INTO message_transports
+        (message_attribute_id,message_transport_type,is_digest,letter_module,letter_code)
+        VALUES
+        (2, 'phone', 0, 'circulation', 'PREDUE'),
+        (2, 'phone', 1, 'circulation', 'PREDUEDGST'),
+        (4, 'phone', 0, 'reserves',    'HOLD')
+        ));
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 21639 - Add phone transports by default)\n";
+}
diff --git a/installer/data/mysql/en/mandatory/sample_notices_message_transports.sql b/installer/data/mysql/en/mandatory/sample_notices_message_transports.sql
index ae68378..5954baf 100644
--- a/installer/data/mysql/en/mandatory/sample_notices_message_transports.sql
+++ b/installer/data/mysql/en/mandatory/sample_notices_message_transports.sql
@@ -3,14 +3,17 @@ insert into `message_transports`
 values
 (1, 'email', 0, 'circulation', 'DUE'),
 (1, 'email', 1, 'circulation', 'DUEDGST'),
-(2, 'email', 0, 'circulation', 'PREDUE'),
-(2, 'email', 1, 'circulation', 'PREDUEDGST'),
-(4, 'email', 0, 'reserves',    'HOLD'),
 (1, 'sms',   0, 'circulation', 'DUE'),
 (1, 'sms',   1, 'circulation', 'DUEDGST'),
+(2, 'email', 0, 'circulation', 'PREDUE'),
+(2, 'email', 1, 'circulation', 'PREDUEDGST'),
 (2, 'sms',   0, 'circulation', 'PREDUE'),
 (2, 'sms',   1, 'circulation', 'PREDUEDGST'),
+(2, 'phone', 0, 'circulation', 'PREDUE'),
+(2, 'phone', 1, 'circulation', 'PREDUEDGST'),
+(4, 'email', 0, 'reserves',    'HOLD'),
 (4, 'sms',   0, 'reserves',    'HOLD'),
+(4, 'phone', 0, 'reserves',    'HOLD'),
 (5, 'email', 0, 'circulation', 'CHECKIN'),
 (5, 'sms',   0, 'circulation', 'CHECKIN'),
 (6, 'email', 0, 'circulation', 'CHECKOUT'),
-- 
2.1.4