mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-14 22:00:16 +02:00
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
This commit is contained in:
parent
9d9037856c
commit
55ea097bce
|
@ -256,10 +256,6 @@ init([ServerHost, Opts]) ->
|
||||||
fun(A) when is_integer(A) andalso A >= 0 -> A end, ?MAXITEMS),
|
fun(A) when is_integer(A) andalso A >= 0 -> A end, ?MAXITEMS),
|
||||||
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts,
|
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts,
|
||||||
fun(A) when is_integer(A) andalso A >= 0 -> A end, undefined),
|
fun(A) when is_integer(A) andalso A >= 0 -> A end, undefined),
|
||||||
case gen_mod:db_type(ServerHost, ?MODULE) of
|
|
||||||
mnesia -> init_mnesia(Host, ServerHost, Opts);
|
|
||||||
_ -> ok
|
|
||||||
end,
|
|
||||||
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
|
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
|
||||||
DefaultModule = plugin(Host, hd(Plugins)),
|
DefaultModule = plugin(Host, hd(Plugins)),
|
||||||
BaseOptions = DefaultModule:options(),
|
BaseOptions = DefaultModule:options(),
|
||||||
|
@ -374,18 +370,6 @@ depends(ServerHost, Opts) ->
|
||||||
end
|
end
|
||||||
end, Plugins).
|
end, Plugins).
|
||||||
|
|
||||||
init_mnesia(Host, ServerHost, Opts) ->
|
|
||||||
pubsub_index:init(Host, ServerHost, Opts),
|
|
||||||
spawn(fun() ->
|
|
||||||
%% maybe upgrade db. this can take time when upgrading existing
|
|
||||||
%% data from ejabberd 2.1.x, so we don't want this to block
|
|
||||||
%% calling gen_server:start
|
|
||||||
pubsub_migrate:update_node_database(Host, ServerHost),
|
|
||||||
pubsub_migrate:update_state_database(Host, ServerHost),
|
|
||||||
pubsub_migrate:update_item_database(Host, ServerHost),
|
|
||||||
pubsub_migrate:update_lastitem_database(Host, ServerHost)
|
|
||||||
end).
|
|
||||||
|
|
||||||
%% @doc Call the init/1 function for each plugin declared in the config file.
|
%% @doc Call the init/1 function for each plugin declared in the config file.
|
||||||
%% The default plugin module is implicit.
|
%% The default plugin module is implicit.
|
||||||
%% <p>The Erlang code for the plugin is located in a module called
|
%% <p>The Erlang code for the plugin is located in a module called
|
||||||
|
|
|
@ -300,46 +300,47 @@ rename_default_nodeplugin() ->
|
||||||
_ = '_'})).
|
_ = '_'})).
|
||||||
|
|
||||||
update_state_database(_Host, _ServerHost) ->
|
update_state_database(_Host, _ServerHost) ->
|
||||||
case catch mnesia:table_info(pubsub_state, attributes) of
|
% useless starting from ejabberd 17.04
|
||||||
[stateid, nodeidx, items, affiliation, subscriptions] ->
|
% case catch mnesia:table_info(pubsub_state, attributes) of
|
||||||
?INFO_MSG("Upgrading pubsub states table...", []),
|
% [stateid, nodeidx, items, affiliation, subscriptions] ->
|
||||||
F = fun ({pubsub_state, {{U,S,R}, NodeID}, _NodeIdx, Items, Aff, Sub}, Acc) ->
|
% ?INFO_MSG("Upgrading pubsub states table...", []),
|
||||||
JID = {U,S,R},
|
% F = fun ({pubsub_state, {{U,S,R}, NodeID}, _NodeIdx, Items, Aff, Sub}, Acc) ->
|
||||||
Subs = case Sub of
|
% JID = {U,S,R},
|
||||||
none ->
|
% Subs = case Sub of
|
||||||
[];
|
% none ->
|
||||||
[] ->
|
% [];
|
||||||
[];
|
% [] ->
|
||||||
_ ->
|
% [];
|
||||||
SubID = pubsub_subscription:make_subid(),
|
% _ ->
|
||||||
[{Sub, SubID}]
|
% SubID = pubsub_subscription:make_subid(),
|
||||||
end,
|
% [{Sub, SubID}]
|
||||||
NewState = #pubsub_state{stateid = {JID, NodeID},
|
% end,
|
||||||
items = Items,
|
% NewState = #pubsub_state{stateid = {JID, NodeID},
|
||||||
affiliation = Aff,
|
% items = Items,
|
||||||
subscriptions = Subs},
|
% affiliation = Aff,
|
||||||
[NewState | Acc]
|
% subscriptions = Subs},
|
||||||
end,
|
% [NewState | Acc]
|
||||||
{atomic, NewRecs} = mnesia:transaction(fun mnesia:foldl/3,
|
% end,
|
||||||
[F, [], pubsub_state]),
|
% {atomic, NewRecs} = mnesia:transaction(fun mnesia:foldl/3,
|
||||||
{atomic, ok} = mnesia:delete_table(pubsub_state),
|
% [F, [], pubsub_state]),
|
||||||
{atomic, ok} = ejabberd_mnesia:create(?MODULE, pubsub_state,
|
% {atomic, ok} = mnesia:delete_table(pubsub_state),
|
||||||
[{disc_copies, [node()]},
|
% {atomic, ok} = ejabberd_mnesia:create(?MODULE, pubsub_state,
|
||||||
{attributes, record_info(fields, pubsub_state)}]),
|
% [{disc_copies, [node()]},
|
||||||
FNew = fun () ->
|
% {attributes, record_info(fields, pubsub_state)}]),
|
||||||
lists:foreach(fun mnesia:write/1, NewRecs)
|
% FNew = fun () ->
|
||||||
end,
|
% lists:foreach(fun mnesia:write/1, NewRecs)
|
||||||
case mnesia:transaction(FNew) of
|
% end,
|
||||||
{atomic, Result} ->
|
% case mnesia:transaction(FNew) of
|
||||||
?INFO_MSG("Pubsub states table upgraded: ~p",
|
% {atomic, Result} ->
|
||||||
[Result]);
|
% ?INFO_MSG("Pubsub states table upgraded: ~p",
|
||||||
{aborted, Reason} ->
|
% [Result]);
|
||||||
?ERROR_MSG("Problem upgrading Pubsub states table:~n~p",
|
% {aborted, Reason} ->
|
||||||
[Reason])
|
% ?ERROR_MSG("Problem upgrading Pubsub states table:~n~p",
|
||||||
end;
|
% [Reason])
|
||||||
_ ->
|
% end;
|
||||||
ok
|
% _ ->
|
||||||
end,
|
% ok
|
||||||
|
% end,
|
||||||
convert_list_subscriptions(),
|
convert_list_subscriptions(),
|
||||||
convert_list_states().
|
convert_list_states().
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user