BEGIN; CREATE TABLE account_users ( id uuid PRIMARY KEY, email text NOT NULL UNIQUE, password_hash text NOT NULL, verified_at timestamptz, created_at timestamptz NOT NULL DEFAULT now() ); CREATE TABLE account_tokens ( digest text PRIMARY KEY, user_id uuid NOT NULL REFERENCES account_users(id) ON DELETE CASCADE, kind text NOT NULL CHECK (kind IN ('verify','session')), expires_at timestamptz NOT NULL ); CREATE INDEX account_tokens_expiry ON account_tokens(expires_at); CREATE TABLE account_limits ( key text PRIMARY KEY, attempts integer NOT NULL, window_start timestamptz NOT NULL ); INSERT INTO schema_migrations(version) VALUES ('014_email_accounts'); COMMIT;