I am trying to have a function that ensures the table I need is already created and if not to create it. Here's the sample:
ensure_table_exists(Table, MnesiaTables, Nodes) ->
case lists:member(Table, MnesiaTables) of
true ->
throw({error, db_might_have_already_been_created});
false ->
mnesia:create_table(Table, [{disc_copies, Nodes},
{attributes, record_info(fields, Table)}]),
ok
end.
Run Code Online (Sandbox Code Playgroud)
The issue is that when compiling I get the error: illegal record info.
It might have to do that record_info is resolved at compile time or that the second argument to record …