mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Reset table only if new def change from runtime
This commit is contained in:
parent
3029e84faf
commit
3482ee5c75
@ -46,7 +46,7 @@ create(Module, Name, TabDef)
|
|||||||
{'EXIT', _} ->
|
{'EXIT', _} ->
|
||||||
mnesia_op(create, [Name, TabDef]);
|
mnesia_op(create, [Name, TabDef]);
|
||||||
Attrs ->
|
Attrs ->
|
||||||
case need_reset(TabDef, Schema) of
|
case need_reset(Name, Schema) of
|
||||||
true -> reset(Name, Schema);
|
true -> reset(Name, Schema);
|
||||||
false -> update(Name, Attrs, Schema)
|
false -> update(Name, Attrs, Schema)
|
||||||
end;
|
end;
|
||||||
@ -152,12 +152,12 @@ parse([{Name, Storage, TabDef}|Tail], Acc)
|
|||||||
parse([Other|_], _) ->
|
parse([Other|_], _) ->
|
||||||
{error, {invalid, Other}}.
|
{error, {invalid, Other}}.
|
||||||
|
|
||||||
need_reset(FromDef, ToDef) ->
|
need_reset(Table, TabDef) ->
|
||||||
ValuesF = [lists:keyfind(Key, 1, FromDef) || Key <- ?NEED_RESET],
|
ValuesF = [mnesia:table_info(Table, Key) || Key <- ?NEED_RESET],
|
||||||
ValuesT = [lists:keyfind(Key, 1, ToDef) || Key <- ?NEED_RESET],
|
ValuesT = [proplists:get_value(Key, TabDef) || Key <- ?NEED_RESET],
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun({Val, Val}, Acc) -> Acc;
|
fun({Val, Val}, Acc) -> Acc;
|
||||||
({_, false}, Acc) -> Acc;
|
({_, undefined}, Acc) -> Acc;
|
||||||
({_, _}, _) -> true
|
({_, _}, _) -> true
|
||||||
end, false, lists:zip(ValuesF, ValuesT)).
|
end, false, lists:zip(ValuesF, ValuesT)).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user