Popularity
5.4
Stable
Activity
0.0
Declining
54
9
5

Description

EctoTrail allows to store Ecto changeset changes in a separate audit_log table.

Monthly Downloads: 120
Programming language: Elixir
License: LISENSE.md
Tags: ORM And Datamapping     Models     Audit    
Latest version: v0.2.0

EctoTrail alternatives and similar packages

Based on the "ORM and Datamapping" category.
Alternatively, view EctoTrail alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of EctoTrail or a related project?

Add another 'ORM and Datamapping' Package

README

EctoTrail

Hex.pm Downloads Latest Version License Build Status Coverage Status Ebert

EctoTrail allows to store changeset changes into a separate audit_log table.

Installation and usage

  1. Add ecto_trail to your list of dependencies in mix.exs:
  def deps do
    [{:ecto_trail, "~> 0.4.0"}]
  end
  1. Ensure ecto_trail is started before your application:
  def application do
    [extra_applications: [:ecto_trail]]
  end
  1. Add a migration that creates audit_log table to priv/repo/migrations folder:
  defmodule EctoTrail.TestRepo.Migrations.CreateAuditLogTable do
    @moduledoc false
    use Ecto.Migration

    def change do
      create table(:audit_log, primary_key: false) do
        add :id, :uuid, primary_key: true
        add :actor_id, :string, null: false
        add :resource, :string, null: false
        add :resource_id, :string, null: false
        add :changeset, :map, null: false

        timestamps([type: :utc_datetime, updated_at: false])
      end
    end
  end
  1. Use EctoTrail in your repo:
  defmodule MyApp.Repo do
    use Ecto.Repo, otp_app: :my_app
    use EctoTrail
  end
  1. Configure table name which is used to store audit log (in config.ex):
  config :ecto_trail, table_name: "audit_log"
  1. Use logging functions instead of defaults. See EctoTrail module docs.

Docs

The docs can be found at https://hexdocs.pm/ecto_trail.


*Note that all licence references and agreements mentioned in the EctoTrail README section above are relevant to that project's source code only.