There's this problem I kept running into - first during my internship, then again on a freelance project I picked up afterward. Both of them used PostgreSQL, and both of them at some point needed an answer to the same question: what did this data look like before?

Could be an audit log. Could be a client asking "what was the price on the 15th?" Could be a bad deployment that nuked a bunch of rows and now someone needs to recover the state from two hours ago.

And every single time, the answer involved the same tedious ritual: add created_at and updated_at columns, create a separate _history table that mirrors the original, write a trigger to populate it on every insert, update, and delete, and hope you got the interval boundaries right. On the freelance project I actually got them wrong on the first try - rows were either double-counted or missing entirely at certain timestamps. Had to tear it out and redo it.

So I finally sat down and built something to handle this properly.

What pgtime does