HACKER Q&A
📣 hchua

How to Do Audit Trail?


We have an internal tool in my company which engineers use to review certain data (let's call them entries), leave comments, approve, reject, KIV them, etc.

We are thinking of creating an audit trail of everything that happens on entries. We want to know "who did what to which entry and when". It seems like the most intuitive way to do this is to create new tables to store such actions and this also means quite a significant amount of code changes need to be made.

Are there other ways to do audit trail? And what if we want to store the old data on top of the actions? It seems like creating tables to store historical data will take up a lot of space.


  👤 mtmail Accepted Answer ✓
In the Ruby on Rails world we have https://github.com/paper-trail-gem/paper_trail It adds a table with event type (create, update, destroy etc), object type (class) and id, and user who initiated it. Optionally a column that stores previous versions.

👤 pestatije
It depends on requirements. It could be a simple log file, or it could be a complete rewrite of the internal tool and database. I would not recommend use an external tool because then the user has double work to do (change entries + add action trail).