Skip to content

Using pghistory for an optimistic concurrency check #167

Closed Answered by wesleykendall
wutje asked this question in Q&A
Discussion options

You must be logged in to vote

I'd argue for using pgtrigger for something like this. For example, here's a trigger example for versioning a model on any change. You can check if the version has been updated without writing snapshots to a totally new table.

If, of course, you're already writing snapshots on every change using pghistory, then you can also use the ID of the history row as a version. Are you wondering if this could go in the library? Seems better suited for a third-party tool

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wutje
Comment options

@wesleykendall
Comment options

Answer selected by wesleykendall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants