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]>
34 lines
1.1 KiB
SQL
34 lines
1.1 KiB
SQL
-- name: UpsertBuild :exec
|
|
INSERT INTO builds
|
|
(id, project_id, service_id, status, progress, started_at, completed_at, image_name, image_tag, size, error, log, metadata, created_at, updated_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13::jsonb, $14, $14)
|
|
ON CONFLICT (id) DO UPDATE SET
|
|
project_id = EXCLUDED.project_id,
|
|
service_id = EXCLUDED.service_id,
|
|
status = EXCLUDED.status,
|
|
progress = EXCLUDED.progress,
|
|
started_at = EXCLUDED.started_at,
|
|
completed_at = EXCLUDED.completed_at,
|
|
image_name = EXCLUDED.image_name,
|
|
image_tag = EXCLUDED.image_tag,
|
|
size = EXCLUDED.size,
|
|
error = EXCLUDED.error,
|
|
log = EXCLUDED.log,
|
|
metadata = EXCLUDED.metadata,
|
|
updated_at = EXCLUDED.updated_at;
|
|
|
|
-- name: GetBuild :one
|
|
SELECT id, project_id, service_id, status, progress, started_at, completed_at, image_name, image_tag, size, error, log, metadata
|
|
FROM builds
|
|
WHERE id = $1;
|
|
|
|
-- name: CancelBuild :execrows
|
|
UPDATE builds
|
|
SET status = 'cancelled',
|
|
progress = 100,
|
|
completed_at = $1,
|
|
log = COALESCE(log, '') || $2,
|
|
updated_at = $1
|
|
WHERE id = $3
|
|
AND status NOT IN ('success', 'failed', 'cancelled');
|