| 1 | BEGIN; |
| 2 | |
| 3 | -- citext compares text without regard to case, so Alice@Example.com and |
| 4 | -- alice@example.com are the same email, and the unique constraint knows it. |
| 5 | CREATE EXTENSION IF NOT EXISTS citext; |
| 6 | |
| 7 | CREATE TABLE users ( |
| 8 | id uuid PRIMARY KEY DEFAULT gen_random_uuid(), |
| 9 | email citext NOT NULL UNIQUE CHECK (length(email) <= 254), |
| 10 | -- argon2id, in the PHC string format: the parameters, the salt and the |
| 11 | -- hash, in one string. Never the password itself. |
| 12 | password_hash text NOT NULL, |
| 13 | created_at timestamptz NOT NULL DEFAULT now() |
| 14 | ); |
| 15 | |
| 16 | COMMIT; |