Mercurial > prosody-hg
comparison tools/migration/migrator/prosody_sql.lua @ 7881:4e3067272fae
tools/migration/migrator/*: Remove use of module()
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 02 Feb 2017 20:49:09 +0100 |
| parents | bd0ff8ae98a8 |
| children | 236b5a6154b2 605fa6bfafd1 |
comparison
equal
deleted
inserted
replaced
| 7880:1d998891c967 | 7881:4e3067272fae |
|---|---|
| 13 | 13 |
| 14 if not have_DBI then | 14 if not have_DBI then |
| 15 error("LuaDBI (required for SQL support) was not found, please see http://prosody.im/doc/depends#luadbi", 0); | 15 error("LuaDBI (required for SQL support) was not found, please see http://prosody.im/doc/depends#luadbi", 0); |
| 16 end | 16 end |
| 17 | 17 |
| 18 module "prosody_sql" | |
| 19 | 18 |
| 20 local function create_table(connection, params) | 19 local function create_table(connection, params) |
| 21 local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);"; | 20 local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);"; |
| 22 if params.driver == "PostgreSQL" then | 21 if params.driver == "PostgreSQL" then |
| 23 create_sql = create_sql:gsub("`", "\""); | 22 create_sql = create_sql:gsub("`", "\""); |
| 108 end | 107 end |
| 109 end | 108 end |
| 110 return userdata; | 109 return userdata; |
| 111 end | 110 end |
| 112 | 111 |
| 113 function reader(input) | 112 local function reader(input) |
| 114 local dbh = assert(DBI.Connect( | 113 local dbh = assert(DBI.Connect( |
| 115 assert(input.driver, "no input.driver specified"), | 114 assert(input.driver, "no input.driver specified"), |
| 116 assert(input.database, "no input.database specified"), | 115 assert(input.database, "no input.database specified"), |
| 117 input.username, input.password, | 116 input.username, input.password, |
| 118 input.host, input.port | 117 input.host, input.port |
| 152 local x = iter(); | 151 local x = iter(); |
| 153 return x and decode_user(x); | 152 return x and decode_user(x); |
| 154 end; | 153 end; |
| 155 end | 154 end |
| 156 | 155 |
| 157 function writer(output, iter) | 156 local function writer(output, iter) |
| 158 local dbh = assert(DBI.Connect( | 157 local dbh = assert(DBI.Connect( |
| 159 assert(output.driver, "no output.driver specified"), | 158 assert(output.driver, "no output.driver specified"), |
| 160 assert(output.database, "no output.database specified"), | 159 assert(output.database, "no output.database specified"), |
| 161 output.username, output.password, | 160 output.username, output.password, |
| 162 output.host, output.port | 161 output.host, output.port |
| 195 end | 194 end |
| 196 end; | 195 end; |
| 197 end | 196 end |
| 198 | 197 |
| 199 | 198 |
| 200 return _M; | 199 return { |
| 200 reader = reader; | |
| 201 writer = writer; | |
| 202 } |
