-- name: CreateSession :one
INSERT INTO sessions (
    id,
    user_id,
    refresh_token,
    user_agent,
    client_ip,
    is_blocked,
    expires_at
 ) VALUES (
    $1, $2, $3, $4, $5, $6, $7
 ) RETURNING *;

-- name: GetSession :one
SELECT * FROM sessions
WHERE id = $1 LIMIT 1;

-- name: GetSessionUserID :one
SELECT * FROM sessions
WHERE user_id = $1 LIMIT 1;

-- name: BlockSession :exec
UPDATE sessions
  set
  is_blocked = true
WHERE id = $1;

-- name: UpdateUserSession :exec
UPDATE sessions
  set
  packhouse_id  = $2,
  exportcompany_id = $3
WHERE id = $1;

-- name: UpdateUserSessionExitPoint :exec
UPDATE sessions
  set
  exitpoint_id  = $2
WHERE id = $1;