Software /
code /
prosody
Comparison
plugins/mod_storage_sql2.lua @ 5740:6fce00f61acf
mod_storage_sql2: Create an additional table `prosodyarchive` for chronological collections
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Jul 2013 01:34:38 +0200 |
parent | 5735:24f4e73645fe |
child | 5741:c7a664e496b3 |
comparison
equal
deleted
inserted
replaced
5739:2e9ad9cb206f | 5740:6fce00f61acf |
---|---|
21 local params = module:get_option("sql"); | 21 local params = module:get_option("sql"); |
22 | 22 |
23 local engine; -- TODO create engine | 23 local engine; -- TODO create engine |
24 | 24 |
25 local function create_table() | 25 local function create_table() |
26 --[[local Table,Column,Index = mod_sql.Table,mod_sql.Column,mod_sql.Index; | 26 local Table,Column,Index = mod_sql.Table,mod_sql.Column,mod_sql.Index; |
27 --[[ | |
27 local ProsodyTable = Table { | 28 local ProsodyTable = Table { |
28 name="prosody"; | 29 name="prosody"; |
29 Column { name="host", type="TEXT", nullable=false }; | 30 Column { name="host", type="TEXT", nullable=false }; |
30 Column { name="user", type="TEXT", nullable=false }; | 31 Column { name="user", type="TEXT", nullable=false }; |
31 Column { name="store", type="TEXT", nullable=false }; | 32 Column { name="store", type="TEXT", nullable=false }; |
76 .."http://prosody.im/doc/mysql for help", | 77 .."http://prosody.im/doc/mysql for help", |
77 err or "unknown error"); | 78 err or "unknown error"); |
78 end | 79 end |
79 end | 80 end |
80 end | 81 end |
82 local ProsodyArchiveTable = Table { | |
83 name="prosodyarchive"; | |
84 Column { name="sort_id", type="INTEGER PRIMARY KEY AUTOINCREMENT", nullable=false }; | |
85 Column { name="host", type="TEXT", nullable=false }; | |
86 Column { name="user", type="TEXT", nullable=false }; | |
87 Column { name="store", type="TEXT", nullable=false }; | |
88 Column { name="key", type="TEXT", nullable=false }; -- item id | |
89 Column { name="when", type="INTEGER", nullable=false }; -- timestamp | |
90 Column { name="with", type="TEXT", nullable=false }; -- related id | |
91 Column { name="type", type="TEXT", nullable=false }; | |
92 Column { name="value", type=params.driver == "MySQL" and "MEDIUMTEXT" or "TEXT", nullable=false }; | |
93 Index { name="prosodyarchive_index", "host", "user", "store", "key" }; | |
94 }; | |
95 engine:transaction(function() | |
96 ProsodyArchiveTable:create(engine); | |
97 end); | |
81 end | 98 end |
82 local function set_encoding() | 99 local function set_encoding() |
83 if params.driver ~= "SQLite3" then | 100 if params.driver ~= "SQLite3" then |
84 local set_names_query = "SET NAMES 'utf8';"; | 101 local set_names_query = "SET NAMES 'utf8';"; |
85 if params.driver == "MySQL" then | 102 if params.driver == "MySQL" then |