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) ->
|
ensure_tables(Tables) when is_list(Tables) ->
|
||||||
lists:foreach(fun ensure_table/1, 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.
|
ok.
|
||||||
|
|
||||||
maybe_add_admin_stats_indexes(Tables) ->
|
%% Indexes required by core_*/logic_* dirty_index_read / index_read paths.
|
||||||
case lists:member(report, Tables) of
|
ensure_indexes(Tables) when is_list(Tables) ->
|
||||||
true -> add_index(report, resolved_by);
|
lists:foreach(fun({Tab, Attrs}) ->
|
||||||
false -> ok
|
case lists:member(Tab, Tables) of
|
||||||
end,
|
true -> lists:foreach(fun(Attr) -> add_index(Tab, Attr) end, Attrs);
|
||||||
case lists:member(ticket, Tables) of
|
false -> ok
|
||||||
true -> add_index(ticket, assigned_to);
|
end
|
||||||
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) ->
|
add_index(Table, Attr) ->
|
||||||
case catch mnesia:add_table_index(Table, Attr) of
|
case catch mnesia:add_table_index(Table, Attr) of
|
||||||
|
|||||||
Reference in New Issue
Block a user