4 ms·
This kinda misses the point, usually you don't want a "delete" in your app, you want an "archive". E.g. given the example it's often desirable to still know tha
by dtech 2y ago
This kinda misses the point, usually you don't want a "delete" in your app, you want an "archive". E.g. given the example it's often desirable to still know that a user used to be part of a group, or to later un-archive the group. That's what soft-deletes are good for.
I'd also recommend against doing audit logging on the application level if you want any kind of coverage, it's to easy to forget or work around. Database triggers or a CDC solution like Debezium [1] have more certainty and as a bonus don't require adding the audit functionality to each individual model.
[1] https://debezium.io/ https://debezium.io/
- jitl 2y agoCDC is great, but in Postgres at least, you can build a very general trigger based audit log by serializing the row in its entirety. Running Kafka, even if it’s managed plus Debezium is hugely more complicated then adding a test that enforces any migration that adds a table also sets up an audit log insert trigger. I’m currently in the process of standing up some Debezium based infra so I’m acutely aware of how annoying and involved it is. There’s also inherent limitations in Debezuium/kafka like maximum message sizes that may not support row shapes that Postgres handles just fine.