From 0e2b9f405cdfdee70e0a15d94d3771c352a13835 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Sat, 4 Feb 2017 00:39:57 +0000 Subject: [PATCH] SQL tweaks to make it more likely that reverting to single language will actually work --- CRM/Core/I18n/Schema.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CRM/Core/I18n/Schema.php b/CRM/Core/I18n/Schema.php index a1fd8be68d..5372e651eb 100644 --- a/CRM/Core/I18n/Schema.php +++ b/CRM/Core/I18n/Schema.php @@ -188,18 +188,20 @@ class CRM_Core_I18n_Schema { } } + $dao = new CRM_Core_DAO(); // deal with columns foreach ($columns[$table] as $column => $type) { - $queries[] = "ALTER TABLE {$table} ADD {$column} {$type}"; - $queries[] = "UPDATE {$table} SET {$column} = {$column}_{$retain}"; + $queries[] = "ALTER TABLE {$table} CHANGE `{$column}_{$retain}` `{$column}` {$type}"; foreach ($locales as $loc) { - $dropQueries[] = "ALTER TABLE {$table} DROP {$column}_{$loc}"; + if (strcmp($loc,$retain) !== 0) { + $dropQueries[] = "ALTER TABLE {$table} DROP {$column}_{$loc}"; + } } } // drop views foreach ($locales as $loc) { - $queries[] = "DROP VIEW {$table}_{$loc}"; + $queries[] = "DROP VIEW IF EXISTS {$table}_{$loc}"; } // add original indices -- 2.25.1