View Source ActiveMemory.Adapters.Mnesia.Migration (ActiveMemory v0.2.2)
Migrations will get run on app startup and are designed to modify :mnesia's schema.
table-copies
Table Copies
In the options
of an ActiveMemory.Table, the copy type and nodes which should have them can be specified.
ram-copies
Ram copies
Tables that only reside in ram on the nodes specified. The default is node()
Example table using default setting:
defmodule Test.Support.Dogs.Dog do
use ActiveMemory.Table,
options: [compressed: true, read_concurrency: true]
.
# module code
.
end
The default will be [node()]
and this table will reside on the node()
ram.
Example table spcifing nodes and ram copies:
defmodule Test.Support.Dogs.Dog do
use ActiveMemory.Table,
options: [compressed: true, read_concurrency: true, ram_copes: [node() | Node.list()]
.
# module code
.
end
All the active nodes in Node.list() and node() will have ram copes of the table.
disc-copies
Disc copies
Disc copy tables reside both in ram and disc on the nodes specified. In order to persist to disc the schema must be setup on at lest one running node. The default is [] (no nodes). Example table spcifing nodes and disc copies:
defmodule Test.Support.Dogs.Dog do
use ActiveMemory.Table,
options: [compressed: true, read_concurrency: true, disc_copes: [node()]
.
# module code
.
end
The table will have a ram copy and disc copy on node()
disc-only-copies
Disc only copies
Disc oly tables reside only on disc on the nodes specified. In order to persist to disc the schema must be setup on at lest one running node. The default is [] (no nodes). Example table spcifing nodes and disc copies:
defmodule Test.Support.Dogs.Dog do
use ActiveMemory.Table,
options: [compressed: true, read_concurrency: true, disc_only_copes: [node()]
.
# module code
.
end
The table will only have a disc copy on node()
table-read-and-write-access
Table Read and Write Access
Mnesia tables can be set to read_only
or read_write
. The default is read_write
.
Read only tables updates cannot be performed.
if you need to change the access use the following syntax: [access_mode: :read_only]
table-types
Table Types
Tables can be either a :set
, :ordered_set
, or a :bag
. The default is :set
if you need to change the type use the following syntax: [type: :bag]
indexes
Indexes
If Indexes are desired specify an atom attribute list for which Mnesia is to build and maintain an extra index table.
The qlc query compiler may be able to optimize queries if there are indexes available.
To specify Indexes use the following syntax: [index: [:age, :hair_color, :cylon?]]
table-load-order
Table Load Order
The load order priority is by default 0 (zero) but can be set to any integer. The tables with the highest load order priority are loaded first at startup.
If you need to change the load order use the following syntax: [load_order: 2]
majority
Majority
If true, any (non-dirty) update to the table is aborted, unless a majority of the table replicas are available for the commit. When used on a fragmented table, all fragments are given the same the same majority setting.
If you need to modify the majority use the following syntax: [majority: true]