Is this the best approach to creating an audit trail?

后端 未结 6 462
滥情空心
滥情空心 2021-01-01 06:05

I\'m trying to create some functionality that keeps an audit trail of how data in a given user form has been changed over time, with a dated audit at the foot of that page.

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 06:48

    I would also think about a database trigger on insert or update to record change details (who, when, what, value before, value after) to a separate audit table. That way you know that even if the data is changed outide of your app using the database directly, it will still be picked up.

    You might also want to do something to detect if the data is changed outide of your app, such as calculate a hash or crc of the record and store it in a field somewhere, then check it when reading the data.

提交回复
热议问题