4 ms·
I've used this approach, but although there are pros and cons I come down against the idea of using triggers to record the history records. Triggers make thing
by ams6110 11y ago
I've used this approach, but although there are pros and cons I come down against the idea of using triggers to record the history records.
Triggers make things happen sort of "by magic" and it's easy to be confused by their behavior and how they impact transactions. You also need to remember to disable them if you ever want to do some kind of bulk update/correction that you don't want recorded in the history.
My approach is to use stored procedures for the updates, and make the history tracking explicit in that code. Overall this is easier to manage, with fewer gotchas.
- sleepychu 11y agoHow do you deal with future developers acting on the table? Triggers ensure that later on I don't develop some new code and forget to update the history (and does all your code deal with inconsistent/damaged history). Perhaps if you're using some sort of abstraction layer then you can make sure that only developers who've read the docs and are aware of semantic links between tables which aren't enforced by the database then this can be mitigated?
- zwentz 11y agoI was about to say the same. I've made a lot of version 2 applications, and version 1 usually has this magic that always causes unintended side effects. Even if it doesn't bite you, it will bite someone else.