]> granicus.if.org Git - ejabberd/commitdiff
Remove obsolete mnesia migration calls
authorChristophe Romain <christophe.romain@process-one.net>
Mon, 3 Apr 2017 09:32:13 +0000 (11:32 +0200)
committerChristophe Romain <christophe.romain@process-one.net>
Mon, 3 Apr 2017 09:37:07 +0000 (11:37 +0200)
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

src/mod_pubsub.erl
src/pubsub_migrate.erl

index 995388cc4c7ea750861b8b1c12e2a8e7e81fd382..5dbd758599e20f19a5490cfafd125f8da828fc3d 100644 (file)
@@ -256,10 +256,6 @@ init([ServerHost, Opts]) ->
            fun(A) when is_integer(A) andalso A >= 0 -> A end, ?MAXITEMS),
     MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts,
            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),
     DefaultModule = plugin(Host, hd(Plugins)),
     BaseOptions = DefaultModule:options(),
@@ -374,18 +370,6 @@ depends(ServerHost, Opts) ->
              end
       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.
 %% The default plugin module is implicit.
 %% <p>The Erlang code for the plugin is located in a module called
index 4d66ea06ea5214eaee6cdb27987955bfb7caf992..17bdb2368888f4fb05f1f0531523c7935c47aa4a 100644 (file)
@@ -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().