mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
21999b49f4
* 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.
70 lines
1.6 KiB
SQL
70 lines
1.6 KiB
SQL
-- name: UpsertSnapshot :one
|
|
INSERT INTO snapshots (
|
|
container_id,
|
|
runtime_snapshot_name,
|
|
display_name,
|
|
parent_runtime_snapshot_name,
|
|
snapshotter,
|
|
source
|
|
)
|
|
VALUES (
|
|
sqlc.arg(container_id),
|
|
sqlc.arg(runtime_snapshot_name),
|
|
sqlc.arg(display_name),
|
|
sqlc.arg(parent_runtime_snapshot_name),
|
|
sqlc.arg(snapshotter),
|
|
sqlc.arg(source)
|
|
)
|
|
ON CONFLICT (container_id, runtime_snapshot_name) DO UPDATE
|
|
SET
|
|
display_name = EXCLUDED.display_name,
|
|
parent_runtime_snapshot_name = EXCLUDED.parent_runtime_snapshot_name,
|
|
snapshotter = EXCLUDED.snapshotter,
|
|
source = EXCLUDED.source
|
|
RETURNING id, container_id, runtime_snapshot_name, display_name, parent_runtime_snapshot_name, snapshotter, source, created_at;
|
|
|
|
-- name: ListSnapshotsByContainerID :many
|
|
SELECT
|
|
id,
|
|
container_id,
|
|
runtime_snapshot_name,
|
|
display_name,
|
|
parent_runtime_snapshot_name,
|
|
snapshotter,
|
|
source,
|
|
created_at
|
|
FROM snapshots
|
|
WHERE container_id = sqlc.arg(container_id)
|
|
ORDER BY created_at DESC;
|
|
|
|
-- name: ListSnapshotsWithVersionByContainerID :many
|
|
SELECT
|
|
s.id,
|
|
s.container_id,
|
|
s.runtime_snapshot_name,
|
|
s.display_name,
|
|
s.parent_runtime_snapshot_name,
|
|
s.snapshotter,
|
|
s.source,
|
|
s.created_at,
|
|
cv.version
|
|
FROM snapshots s
|
|
LEFT JOIN container_versions cv ON cv.snapshot_id = s.id
|
|
WHERE s.container_id = sqlc.arg(container_id)
|
|
ORDER BY s.created_at DESC;
|
|
|
|
-- name: GetSnapshotByContainerAndRuntimeName :one
|
|
SELECT
|
|
id,
|
|
container_id,
|
|
runtime_snapshot_name,
|
|
display_name,
|
|
parent_runtime_snapshot_name,
|
|
snapshotter,
|
|
source,
|
|
created_at
|
|
FROM snapshots
|
|
WHERE container_id = sqlc.arg(container_id)
|
|
AND runtime_snapshot_name = sqlc.arg(runtime_snapshot_name)
|
|
LIMIT 1;
|