Skip to content

Instantly share code, notes, and snippets.

@yosukehara
Created December 26, 2016 08:42
Show Gist options
  • Save yosukehara/081b664934f838339b62cc7fd506bd10 to your computer and use it in GitHub Desktop.
Save yosukehara/081b664934f838339b62cc7fd506bd10 to your computer and use it in GitHub Desktop.
-module(mnesia_test).
-record(store, {key, value}).
-export([start/0, start/1, restart/0]).
start() ->
mnesia:create_schema([node()]),
mnesia:start(),
mnesia:create_table(store, [
{disc_copies, [node()]},
{attributes, record_info(fields, store)}
]).
start(Nodes) ->
mnesia:start(),
mnesia:change_config(extra_db_nodes, Nodes),
mnesia:change_table_copy_type(schema, node(), disc_copies),
mnesia:add_table_copy(store, node(), disc_copies).
restart() ->
mnesia:start().
@yosukehara
Copy link
Author

$ tree . -vhD
.
├── [4.0K Dec 26 17:39]  Mnesia.n0@127.0.0.1
│   ├── [ 152 Dec 26 17:39]  DECISION_TAB.LOG
│   ├── [ 960 Dec 26 17:40]  LATEST.LOG
│   ├── [7.1K Dec 26 17:39]  schema.DAT
│   └── [   8 Dec 26 17:38]  store.DCD
├── [4.0K Dec 26 17:39]  Mnesia.n1@127.0.0.1
│   ├── [ 152 Dec 26 17:39]  DECISION_TAB.LOG
│   ├── [ 992 Dec 26 17:39]  LATEST.LOG
│   ├── [9.6K Dec 26 17:39]  schema.DAT
│   └── [  89 Dec 26 17:39]  store.DCD
├── [1020 Dec 26 17:37]  mnesia_test.beam
└── [ 496 Dec 26 17:37]  mnesia_test.erl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment