MishkaInstaller.Helper.MnesiaAssistant.Table (Mishka installer v0.1.6)

Copy Markdown View Source

Table lifecycle helpers (create / wait / clear / keys).

Summary

Functions

Replicates table (or :schema) to node with the given storage type. Delegates to :mnesia.add_table_copy/3. Returns {:atomic, :ok} or {:aborted, reason}.

Returns every key in table. Delegates to :mnesia.all_keys/1 and must run inside an activity.

Changes the storage type of table (or :schema) on node. Delegates to :mnesia.change_table_copy_type/3. Returns {:atomic, :ok} or {:aborted, reason}.

Removes all records from table. Delegates to :mnesia.clear_table/1.

Creates table from a keyword list of options (:attributes, :index, :disc_copies, ...). Delegates to :mnesia.create_table/2.

Blocks until tables are loaded, up to timeout (ms or :infinity). Delegates to :mnesia.wait_for_tables/2.

Functions

add_table_copy(table, node, type)

@spec add_table_copy(atom(), node(), :ram_copies | :disc_copies | :disc_only_copies) ::
  {:atomic, :ok} | {:aborted, term()}

Replicates table (or :schema) to node with the given storage type. Delegates to :mnesia.add_table_copy/3. Returns {:atomic, :ok} or {:aborted, reason}.

all_keys(table)

@spec all_keys(atom()) :: [term()]

Returns every key in table. Delegates to :mnesia.all_keys/1 and must run inside an activity.

change_table_copy_type(table, node, type)

@spec change_table_copy_type(
  atom(),
  node(),
  :ram_copies | :disc_copies | :disc_only_copies
) ::
  {:atomic, :ok} | {:aborted, term()}

Changes the storage type of table (or :schema) on node. Delegates to :mnesia.change_table_copy_type/3. Returns {:atomic, :ok} or {:aborted, reason}.

clear_table(table)

@spec clear_table(atom()) :: {:atomic, :ok} | {:aborted, term()}

Removes all records from table. Delegates to :mnesia.clear_table/1.

create_table(table, opts)

@spec create_table(
  atom(),
  keyword()
) :: {:atomic, :ok} | {:aborted, term()}

Creates table from a keyword list of options (:attributes, :index, :disc_copies, ...). Delegates to :mnesia.create_table/2.

Returns {:atomic, :ok} or {:aborted, reason}.

wait_for_tables(tables, timeout)

@spec wait_for_tables([atom()], timeout()) ::
  :ok | {:timeout, [atom()]} | {:error, term()}

Blocks until tables are loaded, up to timeout (ms or :infinity). Delegates to :mnesia.wait_for_tables/2.