Skip to content

Commit

Permalink
Add more debug lines
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Apr 16, 2024
1 parent 4613cfc commit cd4fe29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ejabberd_sm_sql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ init() ->
?DEBUG("Cleaning SQL SM table...", []),
lists:foldl(
fun(Host, ok) ->
?INFO_MSG("060 SQL Schema ejabberd_sm_sql:init/0 for host ~p", [ Host ]), %+++
ejabberd_sql_schema:update_schema(Host, ?MODULE, sql_schemas()),
case ejabberd_sql:sql_query(
Host, ?SQL("delete from sm where node=%(Node)s")) of
Expand Down
15 changes: 12 additions & 3 deletions src/ejabberd_sql_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
-include("ejabberd_ctl.hrl").

start(Host) ->
?INFO_MSG("001 SQL Schema: start for host ~p!", [Host]), %+++
case should_update_schema(Host) of
true ->
?INFO_MSG("SQL Schema: Let's update it!", []), %+++
?INFO_MSG("002 SQL Schema: Let's update it for host ~p!", [Host]), %+++
case table_exists(Host, <<"schema_version">>) of
true ->
ok;
Expand All @@ -60,12 +61,12 @@ start(Host) ->
[Table#sql_table.name, Error]),
{error, Error};
_ ->
?INFO_MSG("SQL Schema: created succesfully", []), %+++
?INFO_MSG("003 SQL Schema: created succesfully", []), %+++
ok
end
end;
false ->
?INFO_MSG("SQL Schema: Option to update it was disabled", []), %+++
?INFO_MSG("005 SQL Schema: I will NOT update schema for host ~p.", [Host]), %+++
ok
end.

Expand Down Expand Up @@ -767,15 +768,21 @@ should_update_schema(Host) ->
mysql -> true;
_ -> false
end,
?INFO_MSG("010 SQL Schema should_update_schema - SupportedDB: ~p.", [SupportedDB]), %+++
case ejabberd_option:update_sql_schema() andalso SupportedDB of
true ->
?INFO_MSG("011 SQL Schema should_update_schema - update_sql_schema: ~p.", [true]), %+++
case ejabberd_sql:use_new_schema() of
true ->
?INFO_MSG("012 SQL Schema should_update_schema - use_new_schema: ~p.", [true]), %+++
?INFO_MSG("013 SQL Schema should_update_schema - comparison: ~p == ~p.", [Host, ejabberd_config:get_myname()]), %+++
Host == ejabberd_config:get_myname();
false ->
?INFO_MSG("014 SQL Schema should_update_schema - use_new_schema: ~p.", [false]), %+++
true
end;
false ->
?INFO_MSG("015 SQL Schema should_update_schema - update_sql_schema: ~p.", [false]), %+++
false
end.

Expand Down Expand Up @@ -833,6 +840,7 @@ preprocess_schemas(SchemaInfo, Schemas) ->
end, Schemas).

update_schema(Host, Module, RawSchemas) ->
?INFO_MSG("020 SQL Schema: update_schema/3 for host ~p, Module ~p!", [Host, Module]), %+++
case should_update_schema(Host) of
true ->
SchemaInfo =
Expand Down Expand Up @@ -1204,6 +1212,7 @@ print_schema(SDBType, SDBVersion, SNewSchema) ->


test() ->
?INFO_MSG("030 SQL Schema: test/0", []), %+++
Schemas =
[#sql_schema{
version = 2,
Expand Down

0 comments on commit cd4fe29

Please sign in to comment.