back to TILs

Postgres citext type

TIL about the Postgres citext type (that is, case-insensitive text type), from reading this schema.

Based on this tip from the Postgres docs, this might not be the right type for general text:

Consider using nondeterministic collations (see Section 24.2.2.4) instead of this module. They can be used for case-insensitive comparisons, accent-insensitive comparisons, and other combinations, and they handle more Unicode special cases correctly.

… but if you’re storing something like a username or email address that’s already limited to an ascii-ish character set, and want to keep things unique on a case-insensitive basis, it might be what you’re looking for.