fix(test): add mnesia secondary indexes in eh_test_support
EUnit tables must mirror infra_mnesia:create_indices so dirty_index_read paths in booking/event/search/user do not abort with badarg.
This commit is contained in:
@@ -72,18 +72,34 @@ stop_mnesia() ->
|
||||
|
||||
ensure_tables(Tables) when is_list(Tables) ->
|
||||
lists:foreach(fun ensure_table/1, Tables),
|
||||
maybe_add_admin_stats_indexes(Tables),
|
||||
%% Mirror infra_mnesia:create_indices/0 for tables present in this suite.
|
||||
ensure_indexes(Tables),
|
||||
ok.
|
||||
|
||||
maybe_add_admin_stats_indexes(Tables) ->
|
||||
case lists:member(report, Tables) of
|
||||
true -> add_index(report, resolved_by);
|
||||
false -> ok
|
||||
end,
|
||||
case lists:member(ticket, Tables) of
|
||||
true -> add_index(ticket, assigned_to);
|
||||
false -> ok
|
||||
end.
|
||||
%% Indexes required by core_*/logic_* dirty_index_read / index_read paths.
|
||||
ensure_indexes(Tables) when is_list(Tables) ->
|
||||
lists:foreach(fun({Tab, Attrs}) ->
|
||||
case lists:member(Tab, Tables) of
|
||||
true -> lists:foreach(fun(Attr) -> add_index(Tab, Attr) end, Attrs);
|
||||
false -> ok
|
||||
end
|
||||
end, [
|
||||
{event, [calendar_id, title, created_at, start_time, event_type,
|
||||
master_id, specialist_id, status]},
|
||||
{booking, [event_id, user_id, status]},
|
||||
{review_vote, [review_id, user_id]},
|
||||
{calendar, [owner_id, status, short_name, category]},
|
||||
{calendar_specialist, [calendar_id, user_id]},
|
||||
{specialist_invite, [calendar_id, invitee_user_id, invitee_email, token, status]},
|
||||
{user, [nickname, email]},
|
||||
{verification, [user_id]},
|
||||
{password_reset, [user_id]},
|
||||
{notification, [user_id, is_read]},
|
||||
{auth_session, [family_id, subject_id]},
|
||||
{report, [resolved_by]},
|
||||
{ticket, [assigned_to]}
|
||||
]),
|
||||
ok.
|
||||
|
||||
add_index(Table, Attr) ->
|
||||
case catch mnesia:add_table_index(Table, Attr) of
|
||||
|
||||
Reference in New Issue
Block a user