Software /
code /
prosody-modules
Comparison
mod_migrate/mod_migrate.lua @ 2028:530bf8ef2e55
mod_migrate: Include debug data of what store is being migrated
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 19 Jan 2016 19:52:45 +0100 |
parent | 1985:7821a6986e68 |
child | 2064:2a82c55762a7 |
comparison
equal
deleted
inserted
replaced
2027:d4227837cf06 | 2028:530bf8ef2e55 |
---|---|
20 local storage = module:open_store(source_store, store_type); | 20 local storage = module:open_store(source_store, store_type); |
21 local target = assert(sm.load_driver(host, migrate_to)); | 21 local target = assert(sm.load_driver(host, migrate_to)); |
22 target = assert(target:open(source_store, store_type)); | 22 target = assert(target:open(source_store, store_type)); |
23 | 23 |
24 local function migrate_user(username) | 24 local function migrate_user(username) |
25 module:log("info", "Migrating data for %s", username); | 25 module:log("info", "Migrating %s data for %s", source_store, username); |
26 local data, err = storage:get(username); | 26 local data, err = storage:get(username); |
27 assert(data or err==nil, err); | 27 assert(data or err==nil, err); |
28 assert(target:set(username, data)); | 28 assert(target:set(username, data)); |
29 end | 29 end |
30 | 30 |
31 if store_type == "archive" then | 31 if store_type == "archive" then |
32 function migrate_user(username) | 32 function migrate_user(username) |
33 module:log("info", "Migrating archive items for %s", username); | 33 module:log("info", "Migrating %s archive items for %s", source_store, username); |
34 local count, errs = 0, 0; | 34 local count, errs = 0, 0; |
35 for id, item, when, with in storage:find(username) do | 35 for id, item, when, with in storage:find(username) do |
36 local ok, err = target:append(username, id, item, when, with); | 36 local ok, err = target:append(username, id, item, when, with); |
37 if ok then | 37 if ok then |
38 count = count + 1; | 38 count = count + 1; |