Hacker News new | ask | show | jobs
by TotempaaltJ 2594 days ago
Generally my rule of thumb is to keep the integrity checking as close to the data as possible. Usually that means integrating it into the schema/database (optionally with triggers), as long as that has proper tooling (versioning specifically).

With more complex checks it might be necessary to build a periodically runnable check mechanism. At startup might be a good way to do it, or some sort of cronjob. I can imagine that in larger systems there might even be separate services to check data integrity across other services.

1 comments

I’ve never heard someone say as the database grows in complexity - “I’m so glad we decided to use triggers everywhere”.
I haven't actually used triggers myself, and I do feel like they're too far away from the data to be visible/easy to understand.