4 ms·
I can't find the original post now, but there's a good suggestion that booleans should usually be timestamps: UPDATE orders SET deletion_timestamp = CURRENT_TI
by OscarCunningham 3y ago
I can't find the original post now, but there's a good suggestion that booleans should usually be timestamps:
UPDATE orders SET deletion_timestamp = CURRENT_TIMESTAMP() WHERE deletion_timestamp IS NULL
- AntonZ234 3y agoInteresting, I’ve never heard about that pattern, only is_deleted everywhere
- kamikaz1k 3y agoThis makes more and more sense the more I think about it
- dingnuts 3y agoI can vouch for this pattern from personal experience. From an auditing perspective also, it can be really helpful to know WHEN something was removed.
- adhamsalama 3y agoThat's a good idea.
- FredPret 3y agoI love this pattern
- geekodour 3y agothis seems neat!
- postgressomethi 3y agoWhile that's kind of convenient in a lot of ways, it also makes querying the database really annoying, since you have to remember to add the filtering to every single query or you're screwed. Personally, I wish there was a database-implementation-acknowledged "deleted" flag, which could even expose a "history table"-like interface.
- Karellen 3y agoHow does using a timestamp column make querying the database more annoying than using a boolean column? Aren't the places you have to use filters exactly the same either way?
- postgressomethi 3y agoI'm sorry, I wasn't being clear. Any column meaning "this row is to be ignored for most applications" is an annoying pattern.
- postgressomethi 3y agoAh, now I see I responded to the wrong message.