mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
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.
This commit is contained in:
@@ -362,6 +362,7 @@ type Snapshot struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ContainerID string `json:"container_id"`
|
||||
RuntimeSnapshotName string `json:"runtime_snapshot_name"`
|
||||
DisplayName pgtype.Text `json:"display_name"`
|
||||
ParentRuntimeSnapshotName pgtype.Text `json:"parent_runtime_snapshot_name"`
|
||||
Snapshotter string `json:"snapshotter"`
|
||||
Source string `json:"source"`
|
||||
|
||||
@@ -16,6 +16,7 @@ SELECT
|
||||
id,
|
||||
container_id,
|
||||
runtime_snapshot_name,
|
||||
display_name,
|
||||
parent_runtime_snapshot_name,
|
||||
snapshotter,
|
||||
source,
|
||||
@@ -38,6 +39,7 @@ func (q *Queries) GetSnapshotByContainerAndRuntimeName(ctx context.Context, arg
|
||||
&i.ID,
|
||||
&i.ContainerID,
|
||||
&i.RuntimeSnapshotName,
|
||||
&i.DisplayName,
|
||||
&i.ParentRuntimeSnapshotName,
|
||||
&i.Snapshotter,
|
||||
&i.Source,
|
||||
@@ -51,6 +53,7 @@ SELECT
|
||||
id,
|
||||
container_id,
|
||||
runtime_snapshot_name,
|
||||
display_name,
|
||||
parent_runtime_snapshot_name,
|
||||
snapshotter,
|
||||
source,
|
||||
@@ -73,6 +76,7 @@ func (q *Queries) ListSnapshotsByContainerID(ctx context.Context, containerID st
|
||||
&i.ID,
|
||||
&i.ContainerID,
|
||||
&i.RuntimeSnapshotName,
|
||||
&i.DisplayName,
|
||||
&i.ParentRuntimeSnapshotName,
|
||||
&i.Snapshotter,
|
||||
&i.Source,
|
||||
@@ -93,6 +97,7 @@ SELECT
|
||||
s.id,
|
||||
s.container_id,
|
||||
s.runtime_snapshot_name,
|
||||
s.display_name,
|
||||
s.parent_runtime_snapshot_name,
|
||||
s.snapshotter,
|
||||
s.source,
|
||||
@@ -108,6 +113,7 @@ type ListSnapshotsWithVersionByContainerIDRow struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ContainerID string `json:"container_id"`
|
||||
RuntimeSnapshotName string `json:"runtime_snapshot_name"`
|
||||
DisplayName pgtype.Text `json:"display_name"`
|
||||
ParentRuntimeSnapshotName pgtype.Text `json:"parent_runtime_snapshot_name"`
|
||||
Snapshotter string `json:"snapshotter"`
|
||||
Source string `json:"source"`
|
||||
@@ -128,6 +134,7 @@ func (q *Queries) ListSnapshotsWithVersionByContainerID(ctx context.Context, con
|
||||
&i.ID,
|
||||
&i.ContainerID,
|
||||
&i.RuntimeSnapshotName,
|
||||
&i.DisplayName,
|
||||
&i.ParentRuntimeSnapshotName,
|
||||
&i.Snapshotter,
|
||||
&i.Source,
|
||||
@@ -148,6 +155,7 @@ const upsertSnapshot = `-- name: UpsertSnapshot :one
|
||||
INSERT INTO snapshots (
|
||||
container_id,
|
||||
runtime_snapshot_name,
|
||||
display_name,
|
||||
parent_runtime_snapshot_name,
|
||||
snapshotter,
|
||||
source
|
||||
@@ -157,19 +165,22 @@ VALUES (
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5
|
||||
$5,
|
||||
$6
|
||||
)
|
||||
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, parent_runtime_snapshot_name, snapshotter, source, created_at
|
||||
RETURNING id, container_id, runtime_snapshot_name, display_name, parent_runtime_snapshot_name, snapshotter, source, created_at
|
||||
`
|
||||
|
||||
type UpsertSnapshotParams struct {
|
||||
ContainerID string `json:"container_id"`
|
||||
RuntimeSnapshotName string `json:"runtime_snapshot_name"`
|
||||
DisplayName pgtype.Text `json:"display_name"`
|
||||
ParentRuntimeSnapshotName pgtype.Text `json:"parent_runtime_snapshot_name"`
|
||||
Snapshotter string `json:"snapshotter"`
|
||||
Source string `json:"source"`
|
||||
@@ -179,6 +190,7 @@ func (q *Queries) UpsertSnapshot(ctx context.Context, arg UpsertSnapshotParams)
|
||||
row := q.db.QueryRow(ctx, upsertSnapshot,
|
||||
arg.ContainerID,
|
||||
arg.RuntimeSnapshotName,
|
||||
arg.DisplayName,
|
||||
arg.ParentRuntimeSnapshotName,
|
||||
arg.Snapshotter,
|
||||
arg.Source,
|
||||
@@ -188,6 +200,7 @@ func (q *Queries) UpsertSnapshot(ctx context.Context, arg UpsertSnapshotParams)
|
||||
&i.ID,
|
||||
&i.ContainerID,
|
||||
&i.RuntimeSnapshotName,
|
||||
&i.DisplayName,
|
||||
&i.ParentRuntimeSnapshotName,
|
||||
&i.Snapshotter,
|
||||
&i.Source,
|
||||
|
||||
@@ -67,7 +67,8 @@ SELECT
|
||||
cv.snapshot_id,
|
||||
cv.version,
|
||||
cv.created_at,
|
||||
s.runtime_snapshot_name
|
||||
s.runtime_snapshot_name,
|
||||
s.display_name
|
||||
FROM container_versions cv
|
||||
JOIN snapshots s ON s.id = cv.snapshot_id
|
||||
WHERE cv.container_id = $1
|
||||
@@ -81,6 +82,7 @@ type ListVersionsByContainerIDRow struct {
|
||||
Version int32 `json:"version"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
RuntimeSnapshotName string `json:"runtime_snapshot_name"`
|
||||
DisplayName pgtype.Text `json:"display_name"`
|
||||
}
|
||||
|
||||
func (q *Queries) ListVersionsByContainerID(ctx context.Context, containerID string) ([]ListVersionsByContainerIDRow, error) {
|
||||
@@ -99,6 +101,7 @@ func (q *Queries) ListVersionsByContainerID(ctx context.Context, containerID str
|
||||
&i.Version,
|
||||
&i.CreatedAt,
|
||||
&i.RuntimeSnapshotName,
|
||||
&i.DisplayName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user