Reputation: 8915
This should be simple, although I could not find a way or example yet...
The Mnesia documentation shows how to initialize/create an Mnesia database from the erlang shell, which requires to start the erl shell with the -mnesia parameter:
erl -mnesia dir '"/tmp/funky"'
Once in the shell you can create the schema/etc...
>mnesia:create_schema([node()]).
ok.
>mnesia:start().
ok.
Well, that's simple enough. What if I want to create the schema/etc from another erlang module and I did not start the process with the -mnesia parateter/flag ? I think that basically means, how to dynamically, without running a script but from a pure erlang code approach. For instance, I'd like to do something like this:
-module(something).
-export([test/0]).
test() ->
erlang:setParameter("mnesia","/tmp/funcky"),
mnesia:create_schema([node()]),
...
Upvotes: 0
Views: 229
Reputation: 8915
Well, I think I found the solution. set_env is what I needed:
application:set_env(mnesia, dir, "/tmp/funcky"),
mnesia:create_schema([node()]),
etc...
Upvotes: 1