-- Auth identity uniqueness and lookup hardening.
CREATE UNIQUE INDEX IF NOT EXISTS uq_user_username_active_ci
    ON "user" (lower(username))
    WHERE deleted_at IS NULL;

CREATE UNIQUE INDEX IF NOT EXISTS uq_user_mail_verified_email_ci
    ON user_mail (lower(email))
    WHERE is_verified = true;
