Files
Memoh/db/queries/versions.sql
BBQ 21999b49f4 feat(container): add explicit data workflows and snapshot rollback (#193)
* feat(container): add explicit data workflows and snapshot rollback

Make container upgrades and recreation data-safe by adding explicit preserve, export, import, restore, and rollback flows across the backend, SDK, and web UI.

* fix(container): resolve go lint issues

Fix formatting and lint violations introduced by the container data workflow changes so the Go CI lint job passes cleanly.
2026-03-06 17:57:48 +08:00

33 lines
914 B
SQL

-- name: ListVersionsByContainerID :many
SELECT
cv.id,
cv.container_id,
cv.snapshot_id,
cv.version,
cv.created_at,
s.runtime_snapshot_name,
s.display_name
FROM container_versions cv
JOIN snapshots s ON s.id = cv.snapshot_id
WHERE cv.container_id = sqlc.arg(container_id)
ORDER BY cv.version ASC;
-- name: NextVersion :one
SELECT COALESCE(MAX(version), 0) + 1 FROM container_versions WHERE container_id = sqlc.arg(container_id);
-- name: InsertVersion :one
INSERT INTO container_versions (container_id, snapshot_id, version)
VALUES (
sqlc.arg(container_id),
sqlc.arg(snapshot_id),
sqlc.arg(version)
)
RETURNING id, container_id, snapshot_id, version, created_at;
-- name: GetVersionSnapshotRuntimeName :one
SELECT s.runtime_snapshot_name
FROM container_versions cv
JOIN snapshots s ON s.id = cv.snapshot_id
WHERE cv.container_id = sqlc.arg(container_id)
AND cv.version = sqlc.arg(version);