aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql2.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-10-28 21:34:55 +0100
committerKim Alvefur <zash@zash.se>2013-10-28 21:34:55 +0100
commitaf3f07ec571349201837f6824d992ab877b1b14d (patch)
treedc99a04e3cb1c35c3425a87f1a153fa8633a116e /plugins/mod_storage_sql2.lua
parent4c2ea20af4ca9ea1136a83863bd9b7d2a8469f3f (diff)
downloadprosody-af3f07ec571349201837f6824d992ab877b1b14d.tar.gz
prosody-af3f07ec571349201837f6824d992ab877b1b14d.zip
mod_storage_sql2: Split up setting of encoding and table upgrade code
Diffstat (limited to 'plugins/mod_storage_sql2.lua')
-rw-r--r--plugins/mod_storage_sql2.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua
index 174bad78..7e4de79b 100644
--- a/plugins/mod_storage_sql2.lua
+++ b/plugins/mod_storage_sql2.lua
@@ -108,8 +108,9 @@ local function set_encoding()
local success,err = engine:transaction(function() return engine:execute(set_names_query); end);
if not success then
module:log("error", "Failed to set database connection encoding to UTF8: %s", err);
- return;
end
+end
+local function upgrade_table()
if params.driver == "MySQL" then
-- COMPAT w/pre-0.9: Upgrade tables to UTF-8 if not already
local check_encoding_query = "SELECT `COLUMN_NAME`,`COLUMN_TYPE` FROM `information_schema`.`columns` WHERE `TABLE_NAME`='prosody' AND ( `CHARACTER_SET_NAME`!='utf8' OR `COLLATION_NAME`!='utf8_bin' );";
@@ -149,6 +150,7 @@ do -- process options to get a db connection
-- Encoding mess
set_encoding();
+ upgrade_table();
-- Automatically create table, ignore failure (table probably already exists)
create_table();