Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nebo15/ecto_trail
EctoTrail allows to store Ecto changeset changes in a separate audit_log table.
https://github.com/nebo15/ecto_trail
ecto elixir elixir-lang hex package
Last synced: 7 days ago
JSON representation
EctoTrail allows to store Ecto changeset changes in a separate audit_log table.
- Host: GitHub
- URL: https://github.com/nebo15/ecto_trail
- Owner: Nebo15
- License: mit
- Created: 2017-04-20T11:53:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T16:29:22.000Z (about 1 year ago)
- Last Synced: 2024-12-13T21:30:24.357Z (20 days ago)
- Topics: ecto, elixir, elixir-lang, hex, package
- Language: Elixir
- Homepage: https://hex.pm/packages/ecto_trail
- Size: 49.8 KB
- Stars: 54
- Watchers: 9
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# EctoTrail
[![Hex.pm Downloads](https://img.shields.io/hexpm/dw/ecto_trail.svg?maxAge=3600)](https://hex.pm/packages/ecto_trail) [![Latest Version](https://img.shields.io/hexpm/v/ecto_trail.svg?maxAge=3600)](https://hex.pm/packages/ecto_trail) [![License](https://img.shields.io/hexpm/l/ecto_trail.svg?maxAge=3600)](https://hex.pm/packages/ecto_trail) [![Build Status](https://travis-ci.org/Nebo15/ecto_trail.svg?branch=master)](https://travis-ci.org/Nebo15/ecto_trail) [![Coverage Status](https://coveralls.io/repos/github/Nebo15/ecto_trail/badge.svg?branch=master)](https://coveralls.io/github/Nebo15/ecto_trail?branch=master) [![Ebert](https://ebertapp.io/github/Nebo15/ecto_trail.svg)](https://ebertapp.io/github/Nebo15/ecto_trail)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`:
```elixir
def deps do
[{:ecto_trail, "~> 0.4.0"}]
end
```2. Ensure `ecto_trail` is started before your application:
```elixir
def application do
[extra_applications: [:ecto_trail]]
end
```3. Add a migration that creates `audit_log` table to `priv/repo/migrations` folder:
```elixir
defmodule EctoTrail.TestRepo.Migrations.CreateAuditLogTable do
@moduledoc false
use Ecto.Migrationdef 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: falsetimestamps([type: :utc_datetime, updated_at: false])
end
end
end
```4. Use `EctoTrail` in your repo:
```elixir
defmodule MyApp.Repo do
use Ecto.Repo, otp_app: :my_app
use EctoTrail
end
```5. Configure table name which is used to store audit log (in `config.ex`):
```elixir
config :ecto_trail, table_name: "audit_log"
```6. Use logging functions instead of defaults. See `EctoTrail` module docs.
## Docs
The docs can be found at [https://hexdocs.pm/ecto_trail](https://hexdocs.pm/ecto_trail).