Today I started playing with Hasura and wanted to create a column to store an email address. Usually, I use
varchar(255) (mostly because ORM generates it) but today I found out that citext can also be a good candidate. I want to treat emails as case-insensitive,
email@example.com should be the same as
The citext module provides a case-insensitive character string type, citext. Essentially, it internally calls lower when comparing values. Otherwise, it behaves almost exactly like text.
I wanted to create a column in Hasura console and it turned out that
citext type is not available.
It's not an issue with Hasura! Hasura displays the types supported by the PostgreSQL database to which it is connected. I had to enable
citext extension first.
How to do that?
SQL and run the command below to create an extension.
CREATE EXTENSION IF NOT EXISTS citext;
You can also select
This is a migration and Hasura can automatically create a migration file.
citext type is available now!