-- name: CreateRefreshToken :one
INSERT INTO refresh_tokens (
    usuario_id, token_hash, user_agent, ip, expira_em
) VALUES (
    $1, $2, $3, $4, $5
) RETURNING *;

-- name: GetRefreshToken :one
SELECT * FROM refresh_tokens
WHERE token_hash = $1 LIMIT 1;

-- name: RevokeRefreshToken :exec
UPDATE refresh_tokens
SET revogado = TRUE
WHERE token_hash = $1;

-- name: RevokeAllUserTokens :exec
UPDATE refresh_tokens
SET revogado = TRUE
WHERE usuario_id = $1;
