Documentation
¶
Overview ¶
Package schema fetches and caches database table/column metadata from information_schema so the TUI can include schema context in AI prompts.
The cache lives at ~/.rdq/schema/<sha256(cluster:database)[:16]>.json (overridable via RDQ_SCHEMA_DIR). There is no automatic TTL — users can manually delete a cache file to force a re-fetch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
type Column struct {
Schema string `json:"schema"`
Table string `json:"table"`
Name string `json:"name"`
Type string `json:"type"`
}
Column is one row from information_schema.columns flattened into a struct.
type Snapshot ¶
type Snapshot struct {
Cluster string `json:"cluster"`
Database string `json:"database"`
FetchedAt time.Time `json:"fetched_at"`
Columns []Column `json:"columns"`
}
Snapshot captures the full set of columns for one (cluster, database) pair at a point in time.
func Fetch ¶
func Fetch(ctx context.Context, client *rdsdata.Client, cluster, secret, database string) (*Snapshot, error)
Fetch executes the introspection query against the given cluster and database and returns a Snapshot. Caller is expected to wrap network errors with retry semantics if needed; this function returns them unwrapped so the TUI can decide whether to fall back to an empty schema.
The owner-filtered query is attempted first so PostgreSQL users never see `information_schema` / `pg_catalog` noise in the sidebar. On the first error (typically Aurora MySQL, which lacks schema_owner) it retries with the simple query; only if the retry also fails does the error propagate.
func LoadCache ¶
LoadCache reads a previously-saved Snapshot from disk. A missing file is not an error; callers can interpret nil as "no cache yet".