Fix establishing connection with users
The existing erroneous connections can be found by running:
(fun() ->
T = automate_service_port_channel_user_to_bridge_connection_table,
R = lists:filtermap(fun(K) ->
R = mnesia:dirty_read(T, K),
case R of
[V = {_, _, _, {user, {user, UserId}}, _, _, _}] -> {true, V};
_ -> false
end
end,
mnesia:dirty_all_keys(T))
end)().
And can be fixed with:
(fun() ->
T = automate_service_port_channel_user_to_bridge_connection_table,
mnesia:transform_table(T, fun(R) ->
case R of
{A, B, C, {user, {user, UserId}}, D, E, F} -> {A,B,C,{user, UserId},D,E,F};
X -> X
end
end,
[id,bridge_id,owner,channel_id,name,creation_time])
end)().