Files
uptimesebi/internal/store/queries/agent_storage.sql
Sebastian UnterschützandClaude Opus 5.5 46f1f82481 feat(api): give status page servers sealed key-value storage
Certificates and ACME keys are stored encrypted in the database,
namespaced per owner so an organization's servers cannot read platform
or other organizations' keys. Locks live in Redis and expire.

Refs #22

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 08:54:08 +01:00

17 lines
728 B
SQL

-- name: StorageGet :one
SELECT value, modified FROM agent_storage WHERE owner = $1 AND key = $2;
-- name: StoragePut :exec
INSERT INTO agent_storage (owner, key, value) VALUES ($1, $2, $3)
ON CONFLICT (owner, key) DO UPDATE SET value = EXCLUDED.value, modified = now();
-- name: StorageDelete :execrows
-- Deletes key and, as certmagic expects, everything below it.
DELETE FROM agent_storage
WHERE owner = sqlc.arg(owner) AND (key = sqlc.arg(key) OR starts_with(key, sqlc.arg(key)::text || '/'));
-- name: StorageList :many
SELECT key, length(value)::bigint AS size, modified FROM agent_storage
WHERE owner = sqlc.arg(owner) AND (sqlc.arg(prefix)::text = '' OR starts_with(key, sqlc.arg(prefix)::text || '/'))
ORDER BY key;