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' );";
-- Encoding mess
set_encoding();
+ upgrade_table();
-- Automatically create table, ignore failure (table probably already exists)
create_table();