1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-05 10:39:29 +02:00

Automatically create and update SQL schema

This commit is contained in:
Alexey Shchepin 2023-09-28 03:37:36 +03:00
parent f6e8eb52f0
commit c1af36ac20
28 changed files with 1733 additions and 19 deletions

View file

@ -38,9 +38,25 @@
%%%===================================================================
%%% API
%%%===================================================================
init(_Host, _Opts) ->
init(Host, _Opts) ->
ejabberd_sql_schema:update_schema(Host, ?MODULE, schemas()),
ok.
schemas() ->
[#sql_schema{
version = 1,
tables =
[#sql_table{
name = <<"last">>,
columns =
[#sql_column{name = <<"username">>, type = text},
#sql_column{name = <<"server_host">>, type = text},
#sql_column{name = <<"seconds">>, type = text},
#sql_column{name = <<"state">>, type = text}],
indices = [#sql_index{
columns = [<<"server_host">>, <<"username">>],
unique = true}]}]}].
get_last(LUser, LServer) ->
case ejabberd_sql:sql_query(
LServer,