mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
* refactor(db): port operations, settings, audit, activity, and misc service metadata to sqlc Covers the cross-cutting surface: operations board reads, app settings, notification producers, activity/audit inserts, builds upsert/cancel, git clone credential resolution, invites, environments, registry auth, project/service variables, HA resolver, boot sweeps, and admin user ops. Dynamic filtered lists and Better Auth table probes stay raw by design. Authored By: TDvorak <[email protected]> * refactor(db): port apwhy gateway handlers and proxy data plane to sqlc Final tranche — every static call site now uses generated queries. Raw SQL remains only where the statement is assembled at runtime (filtered lists, sparse updates, admin count closure) or probes Better Auth's auth_users table, which lives outside the local schema. Authored By: TDvorak <[email protected]>
63 lines
2.1 KiB
SQL
63 lines
2.1 KiB
SQL
-- name: GetServiceSleep :one
|
|
SELECT COALESCE(sleep_enabled, false) AS sleep_enabled, COALESCE(sleep_idle_minutes, 15) AS sleep_idle_minutes
|
|
FROM services WHERE id = $1;
|
|
|
|
-- name: GetServiceNodeID :one
|
|
SELECT node_id FROM services WHERE id = $1;
|
|
|
|
-- name: GetServiceSpread :one
|
|
SELECT COALESCE(spread, false) FROM services WHERE id = $1;
|
|
|
|
-- name: GetServicePlacementTags :one
|
|
SELECT placement_tags FROM services WHERE id = $1;
|
|
|
|
-- name: GetServiceTraefikLabels :one
|
|
SELECT traefik_labels FROM services WHERE id = $1;
|
|
|
|
-- name: GetServiceVolumes :one
|
|
SELECT volumes FROM services WHERE id = $1;
|
|
|
|
-- name: GetNodeAgentName :one
|
|
SELECT name FROM node_agents WHERE id = $1;
|
|
|
|
-- name: GetServiceProjectID :one
|
|
SELECT project_id FROM services WHERE id = $1;
|
|
|
|
-- name: GetServiceProjectAndStatus :one
|
|
SELECT s.project_id, COALESCE(s.status, '') AS status
|
|
FROM services s WHERE s.id = $1;
|
|
|
|
-- name: GetEnvironmentProjectID :one
|
|
SELECT project_id FROM environments WHERE id = $1;
|
|
|
|
-- name: GetProjectReadAccess :one
|
|
SELECT is_approved, owner_id::text FROM projects WHERE id = $1;
|
|
|
|
-- name: ProjectMemberExists :one
|
|
SELECT EXISTS(SELECT 1 FROM project_members WHERE project_id = $1 AND user_id = $2);
|
|
|
|
-- name: DeleteEnvVarsForService :exec
|
|
DELETE FROM environment_variables WHERE service_id = $1;
|
|
|
|
-- name: FailInterruptedDeployments :exec
|
|
UPDATE deployments SET status = 'failed', error = 'Interrupted by server restart', completed_at = NOW(), updated_at = NOW()
|
|
WHERE status IN ('queued', 'pending', 'building', 'deploying', 'rolling_back');
|
|
|
|
-- name: ListSecretEnvVars :many
|
|
SELECT id, value FROM environment_variables WHERE is_secret = TRUE;
|
|
|
|
-- name: UpdateEnvVarValue :exec
|
|
UPDATE environment_variables SET value = $1, updated_at = NOW() WHERE id = $2;
|
|
|
|
-- name: ListAgentHealthRows :many
|
|
SELECT id, COALESCE(name, hostname, id::text) AS name, COALESCE(status, '') AS status,
|
|
COALESCE(last_heartbeat < $1, TRUE)::bool AS stale, auto_prune
|
|
FROM node_agents;
|
|
|
|
-- name: SetAgentStatus :exec
|
|
UPDATE node_agents SET status = $1, updated_at = NOW() WHERE id = $2;
|
|
|
|
-- name: GetServiceNameProjectPort :one
|
|
SELECT name, project_id::text, COALESCE(port, 0)::int AS port
|
|
FROM services WHERE id::text = $1;
|