From 0bb8af5ea57e276d2eafa0604135e4bcb25d84a4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 21 May 2014 10:18:38 +0200 Subject: [PATCH] Bug 12298: The "feed" MTT does not seem to be used and can be removed 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 have not been deleted. 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. --- .../de-DE/mandatory/message_transport_types.sql | 1 - .../mysql/en/mandatory/message_transport_types.sql | 1 - .../es-ES/mandatory/message_transport_types.sql | 1 - .../1-Obligatoire/message_transport_types.sql | 1 - .../it-IT/necessari/message_transport_types.sql | 1 - .../1-Obligatorisk/message_transport_types.sql | 1 - .../ru-RU/mandatory/message_transport_types.sql | 1 - .../uk-UA/mandatory/message_transport_types.sql | 1 - installer/data/mysql/updatedatabase.pl | 30 ++++++++++++++++++++++ 9 files changed, 30 insertions(+), 8 deletions(-) diff --git a/installer/data/mysql/de-DE/mandatory/message_transport_types.sql b/installer/data/mysql/de-DE/mandatory/message_transport_types.sql index d4d7de4..ed3c4ad 100644 --- a/installer/data/mysql/de-DE/mandatory/message_transport_types.sql +++ b/installer/data/mysql/de-DE/mandatory/message_transport_types.sql @@ -4,5 +4,4 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/en/mandatory/message_transport_types.sql b/installer/data/mysql/en/mandatory/message_transport_types.sql index d4d7de4..ed3c4ad 100644 --- a/installer/data/mysql/en/mandatory/message_transport_types.sql +++ b/installer/data/mysql/en/mandatory/message_transport_types.sql @@ -4,5 +4,4 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/es-ES/mandatory/message_transport_types.sql b/installer/data/mysql/es-ES/mandatory/message_transport_types.sql index d4d7de4..ed3c4ad 100644 --- a/installer/data/mysql/es-ES/mandatory/message_transport_types.sql +++ b/installer/data/mysql/es-ES/mandatory/message_transport_types.sql @@ -4,5 +4,4 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/message_transport_types.sql b/installer/data/mysql/fr-FR/1-Obligatoire/message_transport_types.sql index 3a90e76..5355973 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/message_transport_types.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/message_transport_types.sql @@ -4,5 +4,4 @@ values ('print'), ('email'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/it-IT/necessari/message_transport_types.sql b/installer/data/mysql/it-IT/necessari/message_transport_types.sql index bf4fd1b..eacb8e5 100644 --- a/installer/data/mysql/it-IT/necessari/message_transport_types.sql +++ b/installer/data/mysql/it-IT/necessari/message_transport_types.sql @@ -6,7 +6,6 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); SET FOREIGN_KEY_CHECKS=1; diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/message_transport_types.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/message_transport_types.sql index 9d9949e..6ff2f66 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/message_transport_types.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/message_transport_types.sql @@ -25,5 +25,4 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/ru-RU/mandatory/message_transport_types.sql b/installer/data/mysql/ru-RU/mandatory/message_transport_types.sql index bf370c8..a789904 100644 --- a/installer/data/mysql/ru-RU/mandatory/message_transport_types.sql +++ b/installer/data/mysql/ru-RU/mandatory/message_transport_types.sql @@ -6,5 +6,4 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/uk-UA/mandatory/message_transport_types.sql b/installer/data/mysql/uk-UA/mandatory/message_transport_types.sql index bf370c8..a789904 100644 --- a/installer/data/mysql/uk-UA/mandatory/message_transport_types.sql +++ b/installer/data/mysql/uk-UA/mandatory/message_transport_types.sql @@ -6,5 +6,4 @@ values ('email'), ('print'), ('sms'), -('feed'), ('phone'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 421e772..6ed6aec 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8471,6 +8471,36 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.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) -- 2.0.0.rc2