3 ms·
If you're going this route, it's hard to understand why you wouldn't just store all the information you want explicitly in a string. "true [timestamp]" "false
by bachmeier 6y ago
If you're going this route, it's hard to understand why you wouldn't just store all the information you want explicitly in a string.
"true [timestamp]"
"false [timestamp]"
"unset [timestamp]"
That's more information than described in the article and it's easier for future you to understand what's going on, without implicit assumptions on the meaning of an undefined variable. Furthermore, you can keep a complete record of all status changes if that's what you want:
"false [timestamp] true [timestamp] false [timestamp] true [timestamp]"
- vbsteven 6y agoThis makes querying harder. You cannot use “is not null” or “= true” for where clauses with this. You’ll need to parse the string value. When going the explicit route I would recommend an is_archived (nullable) bool column combined with an archived_at timestamp column.
- bachmeier 6y agoIf you're using sqlite, for instance, you can call the substr function (I was sticking with the article's constraint to not add a new column). There is one thing in favor of storing the full history in a single string - you might not query the full history very often, and you can keep a lot of information around without adding another table. I've occasionally stored the full history of objects (short notes mostly) in an sqlite database as a string in json form. Pretty convenient if you're keeping it there just in case you want to go back in time and don't make a large number of changes.
- d0100 6y agoAt this point just create a archived_resources table where you store the resource id, timestamp and user id