Добавить автомодерацию: политики, порог жалоб, settings/hits API и тесты.
Refs EventHub/EventHubBack#37 Refs EventHub/EventHubBack#38 Refs EventHub/EventHubBack#39 Refs EventHub/EventHubBack#40
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
%% @doc Create automod_settings and automod_hit tables if missing.
|
||||
-module('20260717150000_automod_tables').
|
||||
|
||||
-export([up/0, down/0]).
|
||||
|
||||
-include("records.hrl").
|
||||
|
||||
up() ->
|
||||
ensure_table(automod_settings, record_info(fields, automod_settings)),
|
||||
ensure_table(automod_hit, record_info(fields, automod_hit)),
|
||||
core_automod_settings:ensure_defaults(),
|
||||
ok.
|
||||
|
||||
down() ->
|
||||
_ = mnesia:delete_table(automod_hit),
|
||||
_ = mnesia:delete_table(automod_settings),
|
||||
ok.
|
||||
|
||||
ensure_table(Table, Attrs) ->
|
||||
case lists:member(Table, mnesia:system_info(tables)) of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
case mnesia:create_table(Table, [{disc_copies, [node()]}, {attributes, Attrs}]) of
|
||||
{atomic, ok} -> ok;
|
||||
{aborted, {already_exists, Table}} -> ok;
|
||||
{aborted, Reason} -> error({create_table_failed, Table, Reason})
|
||||
end
|
||||
end.
|
||||
Reference in New Issue
Block a user