People expect a boolean, by definition, to have a binary nature – true
or false
and nothing else.
But generating a migration with boolean fields defaults to a third option, nil
.
This is confusing. I’ve run into problems multiple times where I assumed an implicit false
value for unset booleans in the database but they were actually nil
. Relying on memory to add false
defaults to generated migrations is error prone.
I suggest the migration generator automatically add default: false
to any boolean fields. On the rare occasions you do not want this behavior, you can simply remove this addition.