-- name: GetRoleByID :one
SELECT * FROM roles
WHERE id = sqlc.arg(id);

-- name: ListRoles :many
SELECT * FROM roles
ORDER BY created_at DESC;

-- name: CreateRole :one
INSERT INTO roles (name, description, created_by)
VALUES (
    sqlc.arg(name),
    sqlc.arg(description),
    sqlc.arg(created_by))
RETURNING *;

-- name: UpdateRole :one
UPDATE roles
SET name = sqlc.arg(name),
    description = sqlc.arg(description)
WHERE id = sqlc.arg(id)
RETURNING *;

-- name: DeleteRole :execrows
DELETE FROM roles
WHERE id = sqlc.arg(id);
