-- name: CreateRefreshToken :one
INSERT INTO refresh_tokens (created_at, updated_at, token, expires_at, revoked_at, user_id)
VALUES (
  NOW(),
  NOW(),
  $1,
  $2,
  $3,
  $4
)
RETURNING *;

-- name: GetRefreshTokenByToken :one
SELECT 
  created_at, 
  updated_at, 
  token, 
  expires_at, 
  revoked_at, 
  user_id 
FROM refresh_tokens
WHERE token = $1;

-- name: RevokeRefreshToken :exec
UPDATE refresh_tokens
SET revoked_at = NOW(), updated_at = NOW()
WHERE token = $1;
