mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 09:49:18 +02:00
Automatically create and update SQL schema
This commit is contained in:
parent
f6e8eb52f0
commit
c1af36ac20
28 changed files with 1733 additions and 19 deletions
|
@ -43,9 +43,40 @@
|
|||
%%%===================================================================
|
||||
%%% 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 = <<"sr_group">>,
|
||||
columns =
|
||||
[#sql_column{name = <<"name">>, type = text},
|
||||
#sql_column{name = <<"server_host">>, type = text},
|
||||
#sql_column{name = <<"opts">>, type = text},
|
||||
#sql_column{name = <<"created_at">>, type = timestamp,
|
||||
default = true}],
|
||||
indices = [#sql_index{
|
||||
columns = [<<"server_host">>, <<"name">>],
|
||||
unique = true}]},
|
||||
#sql_table{
|
||||
name = <<"sr_user">>,
|
||||
columns =
|
||||
[#sql_column{name = <<"jid">>, type = text},
|
||||
#sql_column{name = <<"server_host">>, type = text},
|
||||
#sql_column{name = <<"grp">>, type = text},
|
||||
#sql_column{name = <<"created_at">>, type = timestamp,
|
||||
default = true}],
|
||||
indices = [#sql_index{
|
||||
columns = [<<"server_host">>,
|
||||
<<"jid">>, <<"grp">>],
|
||||
unique = true},
|
||||
#sql_index{
|
||||
columns = [<<"server_host">>, <<"grp">>]}]}]}].
|
||||
|
||||
list_groups(Host) ->
|
||||
case ejabberd_sql:sql_query(
|
||||
Host,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue