// the find
izelnakri/paper_trail
Track and record all the changes in your database with Ecto. Revert back to anytime in history.
An Ecto library that automatically records every insert/update/delete on a schema into a separate versions table, giving you an audit log and the ability to reconstruct a record's history. Aimed at Phoenix/Ecto apps that need change tracking for compliance, debugging, or undo functionality without hand-rolling their own audit tables.
Wraps Repo operations in a transaction, so a failed write never produces an orphaned version record. Strict mode adds foreign-key-backed first_version_id/current_version_id columns, which makes the audit trail queryable with normal joins instead of scanning a loosely-typed versions table. Supports originator tracking (who made the change), multi-tenancy via Ecto's prefix option, and configurable primary key types (UUID, custom), which covers the schema variations real apps actually have.
item_changes stores JSON, so composite and range Postgres types need a hand-written Jason encoder — anyone using those types finds out at runtime, not at compile time. The library has been effectively single-maintainer since 2016, and CHANGELOG/NOTES.md are worth checking before trusting it in strict mode, since that path touches migrations and foreign keys directly. No built-in revert function despite the README's "revert back to anytime in history" pitch — you get the version records, but writing the actual revert logic is on you. Storing the full item_changes on every write means the versions table can grow faster than people expect on high-churn tables, and there's no pruning/retention tooling included.