Software /
code /
prosody-modules
Comparison
mod_log_messages_sql/mod_log_messages_sql.lua @ 2408:9d132153d786
mod_log_messages: Add assert() to detect errors creating SQL table
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 02 Dec 2016 20:47:11 +0000 |
parent | 2407:be08b65f2855 |
comparison
equal
deleted
inserted
replaced
2407:be08b65f2855 | 2408:9d132153d786 |
---|---|
167 module:hook("message/full", message_handler, 2); | 167 module:hook("message/full", message_handler, 2); |
168 | 168 |
169 -- In the telnet console, run: | 169 -- In the telnet console, run: |
170 -- >hosts["this host"].modules.mam_sql.environment.create_sql() | 170 -- >hosts["this host"].modules.mam_sql.environment.create_sql() |
171 function create_sql() | 171 function create_sql() |
172 local stm = getsql([[ | 172 local stm = assert(getsql([[ |
173 CREATE TABLE `]]..table_name..[[` ( | 173 CREATE TABLE `]]..table_name..[[` ( |
174 `host` TEXT, | 174 `host` TEXT, |
175 `user` TEXT, | 175 `user` TEXT, |
176 `store` TEXT, | 176 `store` TEXT, |
177 `id` INTEGER PRIMARY KEY AUTOINCREMENT, | 177 `id` INTEGER PRIMARY KEY AUTOINCREMENT, |
181 `stanza` TEXT | 181 `stanza` TEXT |
182 ); | 182 ); |
183 CREATE INDEX `hus` ON `]]..table_name..[[` (`host`, `user`, `store`); | 183 CREATE INDEX `hus` ON `]]..table_name..[[` (`host`, `user`, `store`); |
184 CREATE INDEX `with` ON `]]..table_name..[[` (`with`); | 184 CREATE INDEX `with` ON `]]..table_name..[[` (`with`); |
185 CREATE INDEX `thetime` ON `]]..table_name..[[` (`when`); | 185 CREATE INDEX `thetime` ON `]]..table_name..[[` (`when`); |
186 ]]); | 186 ]])); |
187 stm:execute(); | 187 stm:execute(); |
188 sql.commit(); | 188 sql.commit(); |
189 end | 189 end |