Ehhh, I don't quite agree with this. I've done the same thing where I used a timestamp field to replace a boolean. However, they are technically not the same thing. In databases, boolean fields can be nullable so you actually have 3-valued boolean logic: true
, false
, and null
. You can technically only replace a non-nullable field to a timestamp column because you are treating null
in timestamp as false
.
Two examples:
-
A table of generated documents for employees to sign. There's a field where they need to agree to something, but it's optional. You want to differentiate between employees who agreed, employees who disagreed, and employees who have yet to agree. You can't change the column from
is_agreed
toagreed_at
. -
Adding a boolean column to an existing table. These columns need to either default to an value (which is fair) or be nullable.
This is pretty par for course for Github.