diff options
author | Christophe Romain <christophe.romain@process-one.net> | 2009-08-20 15:50:24 +0000 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2009-08-20 15:50:24 +0000 |
commit | 49fe1399afb9e5725abd8e7a28ee5bd50bb43bc2 (patch) | |
tree | 329b5ba2130796071d6edd39588848feaac5fdd0 | |
parent | fixing pubsub_subscription issue when changed transaction to sync_dirty (diff) |
add missing index while migrating old pubsub database
SVN Revision: 2509
-rw-r--r-- | src/mod_pubsub/mod_pubsub.erl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index d24b0a40..7135bdb3 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -275,7 +275,7 @@ update_node_database(Host, ServerHost) -> [host_node, host_parent, info] -> ?INFO_MSG("upgrade node pubsub tables",[]), F = fun() -> - lists:foldl( + {Result, LastIdx} = lists:foldl( fun({pubsub_node, NodeId, ParentId, {nodeinfo, Items, Options, Entities}}, {RecList, NodeIdx}) -> ItemsList = lists:foldl( @@ -319,7 +319,9 @@ update_node_database(Host, ServerHost) -> RecList], NodeIdx + 1} end, {[], 1}, mnesia:match_object( - {pubsub_node, {Host, '_'}, '_', '_'})) + {pubsub_node, {Host, '_'}, '_', '_'})), + mnesia:write(#pubsub_index{index = node, last = LastIdx, free = []}), + Result end, {atomic, NewRecords} = mnesia:transaction(F), {atomic, ok} = mnesia:delete_table(pubsub_node), @@ -350,7 +352,7 @@ update_node_database(Host, ServerHost) -> end, mnesia:transform_table(pubsub_node, F, [nodeid, id, parents, type, owners, options]), FNew = fun() -> - lists:foldl(fun(#pubsub_node{nodeid = NodeId} = PubsubNode, NodeIdx) -> + LastIdx = lists:foldl(fun(#pubsub_node{nodeid = NodeId} = PubsubNode, NodeIdx) -> mnesia:write(PubsubNode#pubsub_node{id = NodeIdx}), lists:foreach(fun(#pubsub_state{stateid = StateId} = State) -> {JID, _} = StateId, @@ -370,7 +372,8 @@ update_node_database(Host, ServerHost) -> end, 1, mnesia:match_object( {pubsub_node, {Host, '_'}, '_', '_', '_', '_', '_'}) ++ mnesia:match_object( - {pubsub_node, {{'_', ServerHost, '_'}, '_'}, '_', '_', '_', '_', '_'})) + {pubsub_node, {{'_', ServerHost, '_'}, '_'}, '_', '_', '_', '_', '_'})), + mnesia:write(#pubsub_index{index = node, last = LastIdx, free = []}) end, case mnesia:transaction(FNew) of {atomic, Result} -> |