Skip to content

Commit

Permalink
Added few improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatsuba committed Jul 22, 2020
1 parent bfd8659 commit 9e23cdd
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/admin_extra/service_admin_extra_migration.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ commands() ->

migrate(<<"mnesia">>, <<"rdbms">>, Act) when is_binary(Act) ->
OP = ejabberd_config:get_local_option_or_default(outgoing_pools, []),
case [X || {X, _, _, _, [{_, {_, _, _, _, _, _}}]} <- OP, X =:= rdbms] of
case [X || {X, _, _, _, _} <- OP, X =:= rdbms] of
[rdbms] ->
case try_migrate(Act) of
{ok, Resp} ->
Expand Down Expand Up @@ -168,7 +168,7 @@ migrate_pubsub_nodes([H|_]) ->
Q = ["INSERT INTO pubsub_nodes ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'pubsub_node' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'pubsub_node' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand Down Expand Up @@ -199,7 +199,7 @@ migrate_pubsub_affiliations([H|_]) ->
Q = ["INSERT INTO pubsub_affiliations ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'pubsub_affiliations' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'pubsub_affiliations' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end
Expand Down Expand Up @@ -228,7 +228,7 @@ migrate_pubsub_subscriptions([H|_]) ->
Q = ["INSERT INTO pubsub_subscriptions ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'pubsub_subscriptions' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'pubsub_subscriptions' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end;
Expand Down Expand Up @@ -262,7 +262,7 @@ migrate_pubsub_items([H|_]) ->
Q = ["INSERT INTO pubsub_items ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'pubsub_items' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'pubsub_items' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -285,7 +285,7 @@ migrate_vcard([H|_]) ->
Q = ["INSERT INTO vcard ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'vcard' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'vcard' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand Down Expand Up @@ -316,7 +316,7 @@ migrate_vcard_search([H|_]) ->
Q = ["INSERT INTO vcard_search ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'vcard_search' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'vcard_search' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand Down Expand Up @@ -345,7 +345,7 @@ migrate_users([H|_]) ->
Q = ["INSERT INTO users ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'users' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'users' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -371,7 +371,7 @@ migrate_event_pusher_push_subscription([H|_]) ->
Q = ["INSERT INTO event_pusher_push_subscription ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'event_pusher_push_subscription' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'event_pusher_push_subscription' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -396,7 +396,7 @@ migrate_rosterusers([H|_]) ->
Q = ["INSERT INTO rosterusers ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'rosterusers' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'rosterusers' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -419,7 +419,7 @@ migrate_roster_version([H|_]) ->
Q = ["INSERT INTO roster_version ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'roster_version' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'roster_version' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -443,7 +443,7 @@ migrate_rostergroups([H|_]) ->
Q = ["INSERT INTO rostergroups ", expand_sql_vals(Cols, Vals ++ [Group]), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'rostergroups' has error: ~p for values ~p~n", [Reason, Vals ++ Group]);
?WARNING_MSG("The SQL for 'rostergroups' has error: ~p for values ~p", [Reason, Vals ++ Group]);
_ ->
ok
end
Expand All @@ -468,7 +468,7 @@ migrate_last([H|_]) ->
Q = ["INSERT INTO last ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'last' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'last' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -491,7 +491,7 @@ migrate_private_storage([H|_]) ->
Q = ["INSERT INTO private_storage ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'private_storage' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'private_storage' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand All @@ -515,7 +515,7 @@ migrate_offline_message([H|_]) ->
Q = ["INSERT INTO offline_message ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'offline_message' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'offline_message' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand Down Expand Up @@ -544,7 +544,7 @@ migrate_muc_light_rooms([H|_]) ->
Q = ["INSERT INTO muc_light_rooms ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'muc_light_rooms' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'muc_light_rooms' has error: ~p for values ~p", [Reason, Vals]);
_ ->
migrate_muc_light_config(mod_muc_light_db_mnesia:get_room_config(H), ID),
_ = [migrate_muc_light_occupants(ID, U, S, Aff) || {{U, S}, Aff} <- mod_muc_light_db_mnesia:get_room_aff_users(H)],
Expand All @@ -566,7 +566,7 @@ migrate_muc_light_config([{_, Name}, {_, Subject}], RoomID) ->
Q = ["INSERT INTO muc_light_config ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'muc_light_config' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'muc_light_config' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end.
Expand Down Expand Up @@ -598,7 +598,7 @@ migrate_muc_light_occupants(ID, LUser, LServer, Aff) ->
Q = ["INSERT INTO muc_light_occupants ", expand_sql_vals(Cols, Vals), ";"],
case mongoose_rdbms:sql_query(?MYNAME, Q) of
{error, Reason} ->
io:format("The SQL for 'migrate_muc_light_occupants' has error: ~p for values ~p~n", [Reason, Vals]);
?WARNING_MSG("The SQL for 'migrate_muc_light_occupants' has error: ~p for values ~p", [Reason, Vals]);
_ ->
ok
end
Expand Down

0 comments on commit 9e23cdd

Please sign in to comment.