Memento v0.2.0 Memento.Schema View Source

Module to interact with the database schema.

For persisting data, Mnesia databases need to be created on disk. This module provides an interface to create the database on the disk of the specified nodes. Most of the time that is usually the node that the application is running on.

# Create disk copies on current node
Memento.Schema.create([ node() ]

# Create disk copies on many nodes
node_list = [node(), :alice@host_x, :bob@host_y, :eve@host_z]
Memento.Schema.create(node_list)

Important thing to note here is that only the nodes where data has to be persisted to disk have to be included. RAM-only nodes should be left out. Disk schemas can also be deleted by calling delete/1 and you can get information about them by calling info/0.

Link to this section Summary

Functions

Creates a new database on disk on the specified nodes

Deletes the database previously created by create/1 on the specified nodes

Prints schema information about all Tables to the console

Prints schema information about the specified Table to the console

Link to this section Functions

Link to this function create(nodes) View Source
create([node()]) :: :ok | {:error, any()}

Creates a new database on disk on the specified nodes.

Calling :mnesia.create_schema for a custom path throws an exception if that path does not exist. Memento’s version avoids this by ensuring that the directory exists.

Also see :mnesia.create_schema/1.

Link to this function delete(nodes) View Source
delete([node()]) :: :ok | {:error, any()}

Deletes the database previously created by create/1 on the specified nodes.

Use this with caution, as it makes persisting data obsolete. Also see :mnesia.delete_schema/1.

Prints schema information about all Tables to the console.

Prints schema information about the specified Table to the console.