Comparison

tools/migration/migrator/prosody_sql.lua @ 8066:5eec340c75fb

migration/prosody_sql: Commit transaction when all items have been processed
author Kim Alvefur <zash@zash.se>
date Sat, 08 Apr 2017 16:33:42 +0200
parent 8064:ffb36d1ae23b
child 8068:5abb6bc45edd
child 8073:7361412a9664
comparison
equal deleted inserted replaced
8064:ffb36d1ae23b 8066:5eec340c75fb
159 assert(engine:connect()); 159 assert(engine:connect());
160 assert(engine:delete("DELETE FROM prosody")); 160 assert(engine:delete("DELETE FROM prosody"));
161 local insert_sql = "INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)"; 161 local insert_sql = "INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)";
162 162
163 return function(item) 163 return function(item)
164 if not item then return end -- end of input 164 if not item then assert(engine.conn:commit()) return end -- end of input
165 local host = item.host or ""; 165 local host = item.host or "";
166 local user = item.user or ""; 166 local user = item.user or "";
167 for store, data in pairs(item.stores) do 167 for store, data in pairs(item.stores) do
168 -- TODO transactions 168 -- TODO transactions
169 local extradata = {}; 169 local extradata = {};