pipeline statuscoverage report

Ecto Mnesia Adapter

This adapter brings the strength of Ecto providing validation, and persistance layer to interact to Mnesia databases.

Mnesia is Distributed Database Management System shipped with Erlang runtime. Be aware of strengths and weaknesses listed in erlang documentation before thinking about using it.

What works

  1. Queries
  1. Writing operations

Note: supports only on_conflict: :raise/:update_all

  1. Associations
  1. Transactions

Instalation

You can include ecto3_mnesia in your dependencies as follow:

  defp deps do
    ...
    {:ecto3_mnesia, "~> 0.1.0"}, # not released yet
    ...
  end

Then configure your application repository to use Mnesia adapter as follow:

# ./lib/my_app/repo.ex
defmodule MyApp.Repo do
  use Ecto.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.Mnesia
end

Migrations

Migrations are not supported yet, you can use mnesia abilities to create tables in a script.

# ./priv/repo/mnesia_migration.exs
IO.inspect :mnesia.create_table(:table_name, [
  disc_copies: [node()],
  record_name: MyApp.Context.Schema,
  attributes: [:id, :field, :updated_at, :inserted_at],
  type: :set
])

Then run the script with mix mix run ./priv/repo/mnesia_migration.exs

Notice that the table before MUST be defined according to the corresponding schema

defmodule MyApp.Context.Schema do
  ...
  schema "table_name" do
    field :field, :string

    timestamps()
  end
  ...
end

Tests

You can run the tests as any mix package running

git clone https://gitlab.com/patatoid/ecto3_mnesia.git
cd ecto3_mnesia
mix deps.get
mix test --trace

Contributing

Contributions of any kind are welcome :)