3 ms·
I guess you could work around that by having null in the version column for the active/latest row. Then your queries become 'where version is null' if you want
by aidos 11y ago
I guess you could work around that by having null in the version column for the active/latest row. Then your queries become 'where version is null' if you want to skip superseded rows. You could then use partial indexes (where version is null) to handle unique constraints etc.
EDIT I hadn't finished reading the article, so I didn't see that they were using triggers and the history table. Using the approach I outlined you could keep everything in the same table (if you were that way inclined).
- alternize 11y agowe tried keeping everything in the same table in some web app of ours. we used a version id and an extra versioning status field that kept track of the states "latest published", "latest draft", "archived" which kinda worked fine... the disadvantage is bloat, as in our case the history data was rarely used at all and just there as a safeguard.