[erlang-questions] Initializing mnesia

lloyd@REDACTED lloyd@REDACTED
Fri Oct 9 01:08:47 CEST 2015



Hello,

At first blush, initializing mnesia looks like a piece of cake:

init() ->
    mnesia:create_schema([node()]),
    mnesia:start(),
    mnesia:create_table(....

But suppose one wants to automate it--- "Look, Ma, no hands!" by, say, running it under a top-level supervisor.

Seems we need to:

- check to see if we have a schema
    -- if not, create schema
- check to see if mnesia is running
    -- if not, start it
- check to see if tables are defined
    -- if not, define them

Surfing around I found this:

http://erlang.2086793.n4.nabble.com/When-to-create-mnesia-schema-for-OTP-applications-td2115607.html

Seems to work with Seth Falcon's fix; but the fix produces a warning when compiled. I could live with that, but it bugs me.

Seems to me there must be a more elegant way to solve the problem. Spent half a day on it but the explosion of crash conditions and valid returns put my brain in tilt mode.

It's not like I'm inventing the wheel here. Does some kind should have a simple mean-and-lean solution to the problem?

Many thanks,

LRP










*********************************************
My books:

THE GOSPEL OF ASHES
http://thegospelofashes.com

Strength is not enough. Do they have the courage 
and the cunning? Can they survive long enough to 
save the lives of millions?  

FREEIN' PANCHO
http://freeinpancho.com

A community of misfits help a troubled boy find his way 

AYA TAKEO
http://ayatakeo.com

Star-crossed love, war and power in an alternative 
universe

Available through Amazon or by request from your 
favorite bookstore


**********************************************




More information about the erlang-questions mailing list