Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2015-07-24 14:44:01 +0300
committerChristophe Romain <christophe.romain@process-one.net>2015-07-24 14:44:01 +0300
commit8fedc945bfc1a470a616e7a503d1672ba1f8e6ef (patch)
treec65483e55d04bc8d31021471d0a8381ee6939724 /src/pubsub_migrate.erl
parentd48101774673c35a295fb22b8042d5a5acf4964e (diff)
Allow migration of old pubsub items with xmlelement in body (#479)
Diffstat (limited to 'src/pubsub_migrate.erl')
-rw-r--r--src/pubsub_migrate.erl24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/pubsub_migrate.erl b/src/pubsub_migrate.erl
index e48efcd49..dc01b9af6 100644
--- a/src/pubsub_migrate.erl
+++ b/src/pubsub_migrate.erl
@@ -29,7 +29,8 @@
-include("pubsub.hrl").
-include("logger.hrl").
--export([update_node_database/2, update_state_database/2, update_lastitem_database/2]).
+-export([update_node_database/2, update_state_database/2]).
+-export([update_item_database/2, update_lastitem_database/2]).
update_item_database_binary() ->
F = fun () ->
@@ -57,6 +58,27 @@ update_item_database_binary() ->
?INFO_MSG("Pubsub items table has been binarized: ~p", [Result])
end.
+update_item_database(_Host, _ServerHost) ->
+ F = fun() ->
+ ?INFO_MSG("Migration of old pubsub items...", []),
+ lists:foreach(fun (Key) ->
+ [Item] = mnesia:read({pubsub_item, Key}),
+ Payload = [xmlelement_to_xmlel(El) || El <- Item#pubsub_item.payload],
+ mnesia:write(Item#pubsub_item{payload=Payload})
+ end,
+ mnesia:all_keys(pubsub_item))
+ end,
+ case mnesia:transaction(F) of
+ {aborted, Reason} ->
+ ?ERROR_MSG("Failed to migrate old pubsub items to xmlel: ~p", [Reason]);
+ {atomic, Result} ->
+ ?INFO_MSG("Pubsub items has been migrated: ~p", [Result])
+ end.
+
+xmlelement_to_xmlel({xmlelement, A, B, C}) when is_list(C) ->
+ {xmlel, A, B, [xmlelement_to_xmlel(El) || El <- C]};
+xmlelement_to_xmlel(El) ->
+ El.
update_node_database_binary() ->
F = fun () ->