John Elam - Home | twitter:@elamje | my coding flow playlist: spotify | coding music: List | me now
event sourcing, audit, composition
March 15, 2022

Today I was thinking about how event sourcing works with audit tables. Specifically, I was thinking about the supabase write up on a really nice trigger based solution for audit for CRU operations in Postgres. What I ran into is the question of if we want event sourcing in the long term, and trigger based audit, how are the two related? I was imagining an event sourcing architecture built on Postgres with audit log triggers and the amount of data that would be generated replaying events into the db considering all of those replays would get logged into the audit tables. It would seriously impact performance.

This made me think about how the two are very related. A CRU operation is really an event which means an event can wrap a CRU operation (our audit log tracks these). This provides some nice trigger based composition.

Imagine a new table is used for audit called event. An audit log gets written to this table like a normal event with versioning and json serialization of the audit log event into the data field of the event. This way we don't duplicate data in an huge audit log table and a huge event log table.

Questions to answer:

Links: Event Sourcing Background
Tags: software , django

back. | home.