-- name: CreateRole :one
INSERT INTO roles (
    name,
    description
 ) VALUES (
    $1, $2
 ) RETURNING *;
 
-- name: AttachRole :exec
 INSERT INTO user_roles (
    user_id,
    role_id
 ) VALUES (
    $1, $2
 );
 
-- name: GetRole :one
SELECT * FROM roles
WHERE id = $1 LIMIT 1;

-- name: UpdateRole :one
UPDATE roles
  set 
  name= $2,
  description = $3
WHERE id = $1
RETURNING *;

-- name: DeleteRole :exec
DELETE FROM roles WHERE id= $1;

-- name: ListRoles :many
SELECT * FROM roles
ORDER BY id LIMIT $1
OFFSET $2;

-- name: ListAllRoles :many
SELECT * FROM roles;