F.7. citext
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.
CREATE EXTENSION citext;
CREATE TABLE users (
nick CITEXT PRIMARY KEY,
pass TEXT NOT NULL
);