How to determine if a mnesia schema and table in code have been created?

I want to create the mnesia schema and table in my code after starting the system, so I need to determine the weather when the mnesia schema and table was created. If not, I want to create them. Is that a good idea? And how can I define the mnesia schema and table?

+4
source share
2 answers

One way to handle this is

  • Try creating a table using mnesia:create_table(Table_name, ...)

  • If the table already exists (1), it will return {aborted, {already_exists, Table_name}}

  • If the table does not exit, it will be created and {atomic,ok} will be if successful

  • If an error is created in the table in (3), {aborted, Reason} will be returned.

Process each of these return values โ€‹โ€‹as necessary.

+5
source

Source: https://habr.com/ru/post/1395342/


All Articles