CHECKPOINT -- the full State Store port is in progress; this lands the compile-clean core so the review pass has a diff to work against. Remaining: advisory-lock ownership, event-insert serialization, maintenance, and the ported test battery. Two corrections to behaviour that already shipped, not new features: - UpdateTask wrote park_reason raw where SQLite applies clip(park_reason, 4000); the PostgreSQL adapter now clips before binding (clip.go). - tasks.review_cursor existed on the protobuf wire and in workflow.Task but not in the PostgreSQL schema; 0004 adds it as a NEW migration rather than amending 0001 because a dev database may already have applied 0001 and goose tracks version numbers, not checksums. Also moves the control-plane Resource/ResourceWrite types and their sentinels into storecontract so the postgres package can stop importing internal/store (they stay aliased there for daemon callers).
189 lines
4.6 KiB
Go
189 lines
4.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: status.sql
|
|
|
|
package postgresdb
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const configSnapshotByID = `-- name: ConfigSnapshotByID :one
|
|
SELECT schema, document, published_at FROM config_snapshot WHERE id = 1
|
|
`
|
|
|
|
type ConfigSnapshotByIDRow struct {
|
|
Schema string
|
|
Document string
|
|
PublishedAt time.Time
|
|
}
|
|
|
|
func (q *Queries) ConfigSnapshotByID(ctx context.Context) (ConfigSnapshotByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, configSnapshotByID)
|
|
var i ConfigSnapshotByIDRow
|
|
err := row.Scan(&i.Schema, &i.Document, &i.PublishedAt)
|
|
return i, err
|
|
}
|
|
|
|
const deleteChannelStatusNotIn = `-- name: DeleteChannelStatusNotIn :exec
|
|
DELETE FROM channel_status WHERE NOT (id = ANY($1::text[]))
|
|
`
|
|
|
|
func (q *Queries) DeleteChannelStatusNotIn(ctx context.Context, dollar_1 []string) error {
|
|
_, err := q.db.Exec(ctx, deleteChannelStatusNotIn, dollar_1)
|
|
return err
|
|
}
|
|
|
|
const listApplyStatus = `-- name: ListApplyStatus :many
|
|
SELECT process, kind, applied_version, error, reported_at
|
|
FROM apply_status ORDER BY process, kind
|
|
`
|
|
|
|
func (q *Queries) ListApplyStatus(ctx context.Context) ([]ApplyStatus, error) {
|
|
rows, err := q.db.Query(ctx, listApplyStatus)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ApplyStatus
|
|
for rows.Next() {
|
|
var i ApplyStatus
|
|
if err := rows.Scan(
|
|
&i.Process,
|
|
&i.Kind,
|
|
&i.AppliedVersion,
|
|
&i.Error,
|
|
&i.ReportedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listChannelStatus = `-- name: ListChannelStatus :many
|
|
SELECT id, name, state, detail, configured, reload_supported, observed_at
|
|
FROM channel_status ORDER BY id
|
|
`
|
|
|
|
func (q *Queries) ListChannelStatus(ctx context.Context) ([]ChannelStatus, error) {
|
|
rows, err := q.db.Query(ctx, listChannelStatus)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ChannelStatus
|
|
for rows.Next() {
|
|
var i ChannelStatus
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.State,
|
|
&i.Detail,
|
|
&i.Configured,
|
|
&i.ReloadSupported,
|
|
&i.ObservedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const upsertApplyStatus = `-- name: UpsertApplyStatus :exec
|
|
INSERT INTO apply_status (process, kind, applied_version, error, reported_at)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
ON CONFLICT (process, kind) DO UPDATE SET
|
|
applied_version = excluded.applied_version,
|
|
error = excluded.error,
|
|
reported_at = excluded.reported_at
|
|
`
|
|
|
|
type UpsertApplyStatusParams struct {
|
|
Process string
|
|
Kind string
|
|
AppliedVersion int64
|
|
Error string
|
|
ReportedAt time.Time
|
|
}
|
|
|
|
func (q *Queries) UpsertApplyStatus(ctx context.Context, arg UpsertApplyStatusParams) error {
|
|
_, err := q.db.Exec(ctx, upsertApplyStatus,
|
|
arg.Process,
|
|
arg.Kind,
|
|
arg.AppliedVersion,
|
|
arg.Error,
|
|
arg.ReportedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const upsertChannelStatus = `-- name: UpsertChannelStatus :exec
|
|
INSERT INTO channel_status (id, name, state, detail, configured, reload_supported, observed_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
ON CONFLICT (id) DO UPDATE SET
|
|
name = excluded.name,
|
|
state = excluded.state,
|
|
detail = excluded.detail,
|
|
configured = excluded.configured,
|
|
reload_supported = excluded.reload_supported,
|
|
observed_at = excluded.observed_at
|
|
`
|
|
|
|
type UpsertChannelStatusParams struct {
|
|
ID string
|
|
Name string
|
|
State string
|
|
Detail string
|
|
Configured bool
|
|
ReloadSupported bool
|
|
ObservedAt time.Time
|
|
}
|
|
|
|
func (q *Queries) UpsertChannelStatus(ctx context.Context, arg UpsertChannelStatusParams) error {
|
|
_, err := q.db.Exec(ctx, upsertChannelStatus,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.State,
|
|
arg.Detail,
|
|
arg.Configured,
|
|
arg.ReloadSupported,
|
|
arg.ObservedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const upsertConfigSnapshot = `-- name: UpsertConfigSnapshot :exec
|
|
|
|
INSERT INTO config_snapshot (id, schema, document, published_at)
|
|
VALUES (1, $1, $2, $3)
|
|
ON CONFLICT (id) DO UPDATE SET
|
|
schema = excluded.schema,
|
|
document = excluded.document,
|
|
published_at = excluded.published_at
|
|
`
|
|
|
|
type UpsertConfigSnapshotParams struct {
|
|
Schema string
|
|
Document string
|
|
PublishedAt time.Time
|
|
}
|
|
|
|
// Status projection queries: the published configuration snapshot and the
|
|
// channel / apply-status runtime reports the UI reads across the State Store
|
|
// boundary.
|
|
func (q *Queries) UpsertConfigSnapshot(ctx context.Context, arg UpsertConfigSnapshotParams) error {
|
|
_, err := q.db.Exec(ctx, upsertConfigSnapshot, arg.Schema, arg.Document, arg.PublishedAt)
|
|
return err
|
|
}
|