Question

Long story short, I'm working on a web-based frontend that interacts with a database, and one of the functions is that every action on a particular table gets logged to keep a full history of all changes to that table.

An earlier attempt at using triggers in postgreSQL to handle the logging automatically ran afoul of a couple of other requirements of software that will use said database as a backend, so I'm back to manually creating the log entries and saving them.

My question is, what's best practice? Creating and storing the log first, then making the change, or making the change first, then storing the log? I realize that it's essentially a moot point because I'm wrapping the entire process into a transaction anyway, but I'm suddenly wondering if there are arguments in favor of either methods.

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top