We are in need of some better auditing on some of our MySQL tables. Specifically, we'd like to store when the row was inserted and when it was last updated.
Originally, I thought
DEFAULT CURRENT_TIMESTAMP and
ON UPDATE CURRENT_TIMESTAMP would be perfect, but unfortunately our current MySQL is below version 5.65, so it only supports doing this on one column and thus doesn't meet our needs.
Thus, my next thought was that triggers would be a good solution. However, when I ran this by our DBA, he said that triggers are normally a bad idea and that I should just update the values in the code every place there is an update or insert. This works, but I don't like the fact that it leaves an extra thing for everyone who creates/updates records to worry about, and if they forget then the values will be incorrect. Thus, to me this seems like exactly the case where triggers should be used.
Is this a bad use of a trigger and why?