Software / code / prosody
Comparison
plugins/mod_storage_sql2.lua @ 5884:9cb81a17ae23
mod_storage_sql2: Move checking of the sql_manage_tables option so it also includes table upgrades (again)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 28 Oct 2013 22:08:46 +0100 |
| parent | 5883:39b187e7e892 |
| child | 5891:b6a56934338c |
comparison
equal
deleted
inserted
replaced
| 5883:39b187e7e892 | 5884:9cb81a17ae23 |
|---|---|
| 39 Index { name="prosody_index", "host", "user", "store", "key" }; | 39 Index { name="prosody_index", "host", "user", "store", "key" }; |
| 40 }; | 40 }; |
| 41 engine:transaction(function() | 41 engine:transaction(function() |
| 42 ProsodyTable:create(engine); | 42 ProsodyTable:create(engine); |
| 43 end);]] | 43 end);]] |
| 44 if not module:get_option("sql_manage_tables", true) then | |
| 45 return; | |
| 46 end | |
| 47 | 44 |
| 48 local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);"; | 45 local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);"; |
| 49 if params.driver == "PostgreSQL" then | 46 if params.driver == "PostgreSQL" then |
| 50 create_sql = create_sql:gsub("`", "\""); | 47 create_sql = create_sql:gsub("`", "\""); |
| 51 elseif params.driver == "MySQL" then | 48 elseif params.driver == "MySQL" then |
| 136 --local dburi = db2uri(params); | 133 --local dburi = db2uri(params); |
| 137 engine = mod_sql:create_engine(params); | 134 engine = mod_sql:create_engine(params); |
| 138 | 135 |
| 139 engine:set_encoding(); | 136 engine:set_encoding(); |
| 140 | 137 |
| 141 -- Automatically create table, ignore failure (table probably already exists) | 138 if module:get_option("sql_manage_tables", true) then |
| 142 create_table(); | 139 -- Automatically create table, ignore failure (table probably already exists) |
| 143 -- Encoding mess | 140 create_table(); |
| 144 upgrade_table(); | 141 -- Encoding mess |
| 142 upgrade_table(); | |
| 143 end | |
| 145 end | 144 end |
| 146 | 145 |
| 147 local function serialize(value) | 146 local function serialize(value) |
| 148 local t = type(value); | 147 local t = type(value); |
| 149 if t == "string" or t == "boolean" or t == "number" then | 148 if t == "string" or t == "boolean" or t == "number" then |