May 17, 2020
PostgreSQL, Hasura and citext data type
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,
firstname.lastname@example.org should be the same as
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!