Post

Could you recommend an #ElixirLang library for tracking changes in the database, such as for audit purposes? I need it to work with Postgres and Ecto.

1 repost8 likes

I just realized that, for my purposes, I don't even need Elixir or Ecto. Aside from the UI, this should be achievable with pure SQL. Lo and behold, ChatGPT provided exactly what I needed: a log of JSON-formatted differences for changes in selected tables.

I went for the opposite of overkill and ended up with a pure SQL solution (credits to Claude): bsky.app/profile/mxgr...

Elixir ▷ Max@mxgrn.com

Poor man's audit log for Postgres tables. Pure SQL, no Elixir required. Time-to-shelf: 1 minute. Run the final part for each table you want to audit. Use Postico as the UI. gist.github.com/mxgrn/9900c2...

In the end, didn't even need Postgres events (neither Elixir), went with triggers: bsky.app/profile/mxgr...

Elixir ▷ Max@mxgrn.com

Poor man's audit log for Postgres tables. Pure SQL, no Elixir required. Time-to-shelf: 1 minute. Run the final part for each table you want to audit. Use Postico as the UI. gist.github.com/mxgrn/9900c2...

Oh, did I put it the wrong way?.. Never quite sure about my English skills. What I meant was a "complete" solution, preferably with a UI, where I can go see who changed what when.

Ash is nice, but I haven't yet introduced it into the codebase. Ended up with very incomplete express solution employing pure SQL (triggers, specifically): bsky.app/profile/mxgr...

Elixir ▷ Max@mxgrn.com

Poor man's audit log for Postgres tables. Pure SQL, no Elixir required. Time-to-shelf: 1 minute. Run the final part for each table you want to audit. Use Postico as the UI. gist.github.com/mxgrn/9900c2...