diff options
author | Christophe Romain <christophe.romain@process-one.net> | 2017-04-03 11:32:13 +0200 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2017-04-03 11:37:07 +0200 |
commit | 55ea097bce2b41af3dadf67c3514b3c8674acf07 (patch) | |
tree | 7dcfb4789fa201b4ce8f26e19dc3d8521f47f4de /src/pubsub_migrate.erl | |
parent | Improve redis related code (diff) |
Remove obsolete mnesia migration calls
Now that plugins directly use ejabberd_mnesia and can include their own
transform handler, we don't need pubsub_migrate anymore.
People upgrading from 2.1.1x version must upgrade to 17.01 first.
pubsub_migrate module remains to support any manual process requiring it
Diffstat (limited to 'src/pubsub_migrate.erl')
-rw-r--r-- | src/pubsub_migrate.erl | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/pubsub_migrate.erl b/src/pubsub_migrate.erl index 4d66ea06e..17bdb2368 100644 --- a/src/pubsub_migrate.erl +++ b/src/pubsub_migrate.erl @@ -300,46 +300,47 @@ rename_default_nodeplugin() -> _ = '_'})). update_state_database(_Host, _ServerHost) -> - case catch mnesia:table_info(pubsub_state, attributes) of - [stateid, nodeidx, items, affiliation, subscriptions] -> - ?INFO_MSG("Upgrading pubsub states table...", []), - F = fun ({pubsub_state, {{U,S,R}, NodeID}, _NodeIdx, Items, Aff, Sub}, Acc) -> - JID = {U,S,R}, - Subs = case Sub of - none -> - []; - [] -> - []; - _ -> - SubID = pubsub_subscription:make_subid(), - [{Sub, SubID}] - end, - NewState = #pubsub_state{stateid = {JID, NodeID}, - items = Items, - affiliation = Aff, - subscriptions = Subs}, - [NewState | Acc] - end, - {atomic, NewRecs} = mnesia:transaction(fun mnesia:foldl/3, - [F, [], pubsub_state]), - {atomic, ok} = mnesia:delete_table(pubsub_state), - {atomic, ok} = ejabberd_mnesia:create(?MODULE, pubsub_state, - [{disc_copies, [node()]}, - {attributes, record_info(fields, pubsub_state)}]), - FNew = fun () -> - lists:foreach(fun mnesia:write/1, NewRecs) - end, - case mnesia:transaction(FNew) of - {atomic, Result} -> - ?INFO_MSG("Pubsub states table upgraded: ~p", - [Result]); - {aborted, Reason} -> - ?ERROR_MSG("Problem upgrading Pubsub states table:~n~p", - [Reason]) - end; - _ -> - ok - end, +% useless starting from ejabberd 17.04 +% case catch mnesia:table_info(pubsub_state, attributes) of +% [stateid, nodeidx, items, affiliation, subscriptions] -> +% ?INFO_MSG("Upgrading pubsub states table...", []), +% F = fun ({pubsub_state, {{U,S,R}, NodeID}, _NodeIdx, Items, Aff, Sub}, Acc) -> +% JID = {U,S,R}, +% Subs = case Sub of +% none -> +% []; +% [] -> +% []; +% _ -> +% SubID = pubsub_subscription:make_subid(), +% [{Sub, SubID}] +% end, +% NewState = #pubsub_state{stateid = {JID, NodeID}, +% items = Items, +% affiliation = Aff, +% subscriptions = Subs}, +% [NewState | Acc] +% end, +% {atomic, NewRecs} = mnesia:transaction(fun mnesia:foldl/3, +% [F, [], pubsub_state]), +% {atomic, ok} = mnesia:delete_table(pubsub_state), +% {atomic, ok} = ejabberd_mnesia:create(?MODULE, pubsub_state, +% [{disc_copies, [node()]}, +% {attributes, record_info(fields, pubsub_state)}]), +% FNew = fun () -> +% lists:foreach(fun mnesia:write/1, NewRecs) +% end, +% case mnesia:transaction(FNew) of +% {atomic, Result} -> +% ?INFO_MSG("Pubsub states table upgraded: ~p", +% [Result]); +% {aborted, Reason} -> +% ?ERROR_MSG("Problem upgrading Pubsub states table:~n~p", +% [Reason]) +% end; +% _ -> +% ok +% end, convert_list_subscriptions(), convert_list_states(). |