mod_storage_sql2: Move checking of the sql_manage_tables option so it also includes...
authorKim Alvefur <zash@zash.se>
Mon, 28 Oct 2013 21:08:46 +0000 (22:08 +0100)
committerKim Alvefur <zash@zash.se>
Mon, 28 Oct 2013 21:08:46 +0000 (22:08 +0100)
plugins/mod_storage_sql2.lua

index 0e6aca3ad4baa601d81260e86cb28b9ebc3e1713..4148024e720f4fc0b7dd48fb51172761ef1b2434 100644 (file)
@@ -41,9 +41,6 @@ local function create_table()
        engine:transaction(function()
                ProsodyTable:create(engine);
        end);]]
-       if not module:get_option("sql_manage_tables", true) then
-               return;
-       end
 
        local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);";
        if params.driver == "PostgreSQL" then
@@ -138,10 +135,12 @@ do -- process options to get a db connection
 
        engine:set_encoding();
 
-       -- Automatically create table, ignore failure (table probably already exists)
-       create_table();
-       -- Encoding mess
-       upgrade_table();
+       if module:get_option("sql_manage_tables", true) then
+               -- Automatically create table, ignore failure (table probably already exists)
+               create_table();
+               -- Encoding mess
+               upgrade_table();
+       end
 end
 
 local function serialize(value)