Bug 12298: The "feed" MTT does not seem to be used and can be removed
authorJonathan Druart <jonathan.druart@biblibre.com>
Wed, 21 May 2014 08:18:38 +0000 (10:18 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 25 Nov 2014 20:14:50 +0000 (17:14 -0300)
The feed message transport type exists but nobody knows how it can be
used. This patch assumes nobody uses it and removes it.

Before removing the entry in the DB, the updatedb entry will check if no
foreign key exists in order to avoid a delete in cascade.

This path does *not* deletes the occurrences in the templates.

Test plan:
Apply this patch, execute the updatedb script and verify the
message_transport_types table does not contain the 'feed' entry if it was not
in use.

Signed-off-by: Nick Clemens <nick@quecheelibrary.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Patch will remove the confusing option to configure message texts for feeds.
Checked on a database with an existing feed type notice (not deleted) and
on one without any references to the feed message transport type (deleted!)

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
installer/data/mysql/de-DE/mandatory/message_transport_types.sql
installer/data/mysql/en/mandatory/message_transport_types.sql
installer/data/mysql/es-ES/mandatory/message_transport_types.sql
installer/data/mysql/fr-FR/1-Obligatoire/message_transport_types.sql
installer/data/mysql/it-IT/necessari/message_transport_types.sql
installer/data/mysql/nb-NO/1-Obligatorisk/message_transport_types.sql
installer/data/mysql/ru-RU/mandatory/message_transport_types.sql
installer/data/mysql/uk-UA/mandatory/message_transport_types.sql
installer/data/mysql/updatedatabase.pl

index 03801e0..5442e0f 100755 (executable)
@@ -9543,6 +9543,36 @@ if ( CheckVersion($DBversion) ) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.17.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    my $count_l = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM letter WHERE message_transport_type='feed'
+    |);
+    my $count_mq = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM message_queue WHERE message_transport_type='feed'
+    |);
+    my $count_ott = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM overduerules_transport_types WHERE message_transport_type='feed'
+    |);
+    my $count_mt = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM message_transports WHERE message_transport_type='feed'
+    |);
+    my $count_bmtp = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM borrower_message_transport_preferences WHERE message_transport_type='feed'
+    |);
+
+    my $deleted = 0;
+    if ( $count_l->[0] == 0 and $count_mq->[0] == 0 and $count_ott->[0] == 0 and $count_mt->[0] == 0 and $count_bmtp->[0] == 0 ) {
+        $deleted = $dbh->do(q|
+            DELETE FROM message_transport_types where message_transport_type='feed'
+        |);
+        $deleted = $deleted ne '0E0' ? 1 : 0;
+    }
+
+    print "Upgrade to $DBversion done (Bug 12298: Delete the 'feed' message transport type " . ($deleted ? '(deleted!)' : '(not deleted)') . ")\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)