diff --git a/src/ejabberd_sql_schema.erl b/src/ejabberd_sql_schema.erl index a4eaea0b2..af9743f82 100644 --- a/src/ejabberd_sql_schema.erl +++ b/src/ejabberd_sql_schema.erl @@ -293,6 +293,7 @@ string_to_type(SType) -> <<"integer">> -> integer; <<"int">> -> integer; <<"int(", _/binary>> -> integer; + <<"int ", _/binary>> -> integer; <<"smallint">> -> smallint; <<"smallint(", _/binary>> -> smallint; <<"numeric">> -> numeric; @@ -300,6 +301,7 @@ string_to_type(SType) -> <<"bigserial">> -> bigserial; <<"boolean">> -> boolean; <<"tinyint(1)">> -> boolean; + <<"tinyint", _/binary>> -> smallint; <<"bytea">> -> blob; <<"blob">> -> blob; <<"timestamp", _/binary>> -> timestamp; @@ -340,6 +342,8 @@ check_columns_compatibility(RequiredColumns, Columns) -> {integer, bigint} -> true; {integer, numeric} -> true; {bigint, numeric} -> true; + %% a workaround for MySQL definition of mqtt_pub + {bigint, integer} -> true; {bigserial, integer} -> true; {bigserial, bigint} -> true; {bigserial, numeric} -> true; @@ -768,7 +772,17 @@ should_update_schema(Host) -> true -> case ejabberd_sql:use_new_schema() of true -> - Host == ejabberd_config:get_myname(); + %% TODO: not efficient when there are many hosts + case lists:search( + fun(H) -> + lists:member( + sql, ejabberd_option:auth_method(H)) + end, ejabberd_option:hosts()) of + {value, Host} -> + true; + _ -> + false + end; false -> true end; diff --git a/src/mod_mqtt_sql.erl b/src/mod_mqtt_sql.erl index a57628372..f7bfea717 100644 --- a/src/mod_mqtt_sql.erl +++ b/src/mod_mqtt_sql.erl @@ -58,7 +58,7 @@ sql_schemas() -> #sql_column{name = <<"content_type">>, type = text}, #sql_column{name = <<"response_topic">>, type = text}, #sql_column{name = <<"correlation_data">>, type = blob}, - #sql_column{name = <<"user_property">>, type = blob}, + #sql_column{name = <<"user_properties">>, type = blob}, #sql_column{name = <<"expiry">>, type = bigint}], indices = [#sql_index{ columns = [<<"topic">>, <<"server_host">>],