-- name: CreateSecurityProfile :one
INSERT INTO security_profiles (name, risk_level)
VALUES ($1, $2)
RETURNING *;

-- name: CreatePolicy :one
INSERT INTO policies (name, description)
VALUES ($1, $2)
RETURNING *;

-- name: CreateControl :one
INSERT INTO controls (policy_id, name, description)
VALUES ($1, $2, $3)
RETURNING *;

-- name: CreateFinding :one
INSERT INTO findings (control_id, resource_id, status, details)
VALUES ($1, $2, $3, $4)
RETURNING *;

-- name: ListFindings :many
SELECT * FROM findings
WHERE status = $1;

-- name: CreateAuditLog :one
INSERT INTO audit_logs (actor_id, action, resource_type, resource_id, details)
VALUES ($1, $2, $3, $4, $5)
RETURNING *;

-- name: ListAuditLogs :many
SELECT * FROM audit_logs
ORDER BY timestamp DESC
LIMIT $1 OFFSET $2;
