common

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess             = 0 // Success
	ExitGeneralError        = 1 // General error
	ExitTimeout             = 2 // Operation timeout (wait-timeout exceeded) or connection timeout
	ExitInvalidParameters   = 3 // Invalid parameters
	ExitAuthenticationError = 4 // Authentication error
	ExitPermissionDenied    = 5 // Permission denied
	ExitServiceNotFound     = 6 // Service not found
	ExitUpdateAvailable     = 7 // Update available
)

Exit codes as defined in the CLI specification

View Source
const (
	AddonNone       = "none" // Special value for no add-ons
	AddonTimeSeries = "time-series"
	AddonAI         = "ai"
)

Addon constants - these match the ServiceCreateAddons from the API

Variables

View Source
var (
	// ErrPaused is returned for a paused (or pausing) service.
	ErrPaused = errors.New("service is paused")

	// ErrNotReady is returned for a service that isn't accepting connections
	// (provisioning, resuming, upgrading, deleting, etc.).
	ErrNotReady = errors.New("service is not ready")
)
View Source
var ErrReadOnly = errors.New("this operation is not allowed in read-only mode")

ErrReadOnly is returned when a destructive operation is attempted while read-only mode is enabled in the user's config.

View Source
var (
	// GetStoredCredentials loads the stored credentials (PAT or OAuth) from the
	// keyring or fallback file. It's a package var so tests can override it to
	// inject credentials of either shape.
	GetStoredCredentials = config.GetStoredCredentials
)

Functions

func CheckReadOnly added in v0.20.4

func CheckReadOnly(cfg *config.Config) error

CheckReadOnly returns ErrReadOnly if read-only mode is enabled. Callers should invoke this before any destructive API call.

func CheckServiceReady added in v0.21.0

func CheckServiceReady(service api.Service) error

CheckServiceReady returns nil only when the service is READY, ErrPaused for PAUSED/PAUSING, and ErrNotReady for every other (or unknown) status.

func ConnectToService added in v0.21.0

func ConnectToService(ctx context.Context, service api.Service, opts ConnectionDetailsOptions, mode pgx.QueryExecMode) (*pgx.Conn, error)

ConnectToService resolves the service's connection details and opens a pgx connection using the given query execution mode. It is the shared service-to-connection path used by the query and schema tools. The caller owns the returned connection and must Close it.

func ExitWithCode

func ExitWithCode(code int, err error) error

ExitWithCode returns an error that will cause the program to exit with the specified code

func ExitWithErrorFromStatusCode

func ExitWithErrorFromStatusCode(statusCode int, err error) error

ExitWithErrorFromStatusCode maps HTTP status codes to CLI exit codes

func FetchServiceLogs added in v0.20.0

func FetchServiceLogs(
	ctx context.Context,
	cfg *Config,
	serviceID string,
	tail int,
	since *time.Time,
	until *time.Time,
	node *int,
) ([]api.ServiceLogEntry, error)

FetchServiceLogs fetches service logs with cursor-based pagination up to the specified tail limit. Returns entries in ascending order by timestamp (oldest first, newest last). NOTE: The node parameter specifies the specific service node to fetch logs from, for services with HA replicas. If nil, the backend automatically returns logs for the primary.

func FormatSchema added in v0.21.0

func FormatSchema(schema *DatabaseSchema) string

FormatSchema formats a DatabaseSchema into a human-readable string, grouping objects under a SCHEMA: <name> header for each namespace. When includeDefinitions is false, the verbose object source bodies (view defining SELECTs and function/procedure bodies) are omitted, leaving just the structural summary (columns, constraints, indexes, signatures, etc.). When includeComments is true, object comments (COMMENT ON text) render as "-- " annotation lines under each object header and inline after columns.

func GenerateServiceName

func GenerateServiceName() string

Matches front-end logic for generating a random service name

func GetPassword

func GetPassword(service api.Service, role string) (string, error)

GetPassword fetches the password for the specified service from the configured password storage mechanism. It returns an error if it fails to find the password.

func IdentifyOAuthUser added in v0.20.5

func IdentifyOAuthUser(ctx context.Context, cfg *config.Config, client *api.ClientWithResponses, projectID string)

IdentifyOAuthUser sends an analytics Identify for an OAuth (PKCE) login, using the token-authenticated client built during login. It fetches the caller's identity via /auth/info. Best-effort.

func IsValidAddon

func IsValidAddon(addon string) bool

IsValidAddon checks if the given add-on is valid (case-sensitive as per API spec)

func NewAPIClient added in v0.19.5

func NewAPIClient(ctx context.Context, cfg *config.Config) (*api.ClientWithResponses, string, error)

NewAPIClient initializes a api.ClientWithResponses and returns it along with the current project ID. Credentials are pulled from the environment (if present), or loaded from storage (either the keyring or fallback file). When pulled from the environment, the credentials are first validated by hitting the /auth/info endpoint (which also allows us to fetch the project ID), and the user is identified for the sake of analytics by hitting the /analytics/identify endpoint. When credentials are pulled from storage, those operations should have already been performed via `tiger auth login`.

func ParseCPUMemory

func ParseCPUMemory(cpuMemoryStr string) (string, string, error)

ParseCPUMemory parses a CPU/memory combination string (e.g., "2 CPU/8GB") and returns millicores and GB. If "shared" is given, returns "shared" for both CPU and memory.

func ValidAddons

func ValidAddons() []string

ValidAddons returns a slice of all valid add-on values

func ValidateAPIKey added in v0.19.5

func ValidateAPIKey(ctx context.Context, cfg *config.Config, client *api.ClientWithResponses) (*api.AuthInfo, error)

ValidateAPIKey validates the API key by calling the /auth/info endpoint, and returns the caller's identity. It also identifies the user for the sake of analytics. Only PAT credentials reach this path, so the response always carries the apiKey branch.

func ValidateAddons

func ValidateAddons(addons []string) ([]string, error)

ValidateAddons validates a slice of add-ons and removes duplicate values

func WaitForService

func WaitForService(ctx context.Context, args WaitForServiceArgs) error

Types

type CPUMemoryConfig

type CPUMemoryConfig struct {
	Shared    bool // Shared CPU/Memory
	CPUMillis int  // CPU in millicores
	MemoryGBs int  // Memory in GB
}

CPUMemoryConfig represents an allowed CPU/Memory configuration

func ValidateAndNormalizeCPUMemory

func ValidateAndNormalizeCPUMemory(cpuMillis, memoryGBs string) (*CPUMemoryConfig, error)

ValidateAndNormalizeCPUMemory validates CPU/Memory values and applies auto-configuration logic

func (*CPUMemoryConfig) CPUMillisString added in v0.20.0

func (c *CPUMemoryConfig) CPUMillisString() *string

func (*CPUMemoryConfig) Matches

func (c *CPUMemoryConfig) Matches(cpuMillis, memoryGBs string) bool

func (*CPUMemoryConfig) MemoryGBsString added in v0.20.0

func (c *CPUMemoryConfig) MemoryGBsString() *string

func (*CPUMemoryConfig) String

func (c *CPUMemoryConfig) String() string

type CPUMemoryConfigs

type CPUMemoryConfigs []CPUMemoryConfig

func GetAllowedCPUMemoryConfigs

func GetAllowedCPUMemoryConfigs() CPUMemoryConfigs

GetAllowedCPUMemoryConfigs returns the allowed CPU/Memory configurations from the spec

func GetAllowedResizeCPUMemoryConfigs added in v0.20.0

func GetAllowedResizeCPUMemoryConfigs() CPUMemoryConfigs

GetAllowedResizeCPUMemoryConfigs returns the allowed CPU/Memory configurations for resize operations (excludes shared)

func (CPUMemoryConfigs) String

func (c CPUMemoryConfigs) String() string

String returns a user-friendly string of allowed CPU/Memory combinations

func (CPUMemoryConfigs) Strings

func (c CPUMemoryConfigs) Strings() []string

Strings returns a slice of user-friendly strings of allowed CPU/Memory combinations

type CheckConstraint added in v0.21.0

type CheckConstraint struct {
	Name       string   `json:"name"`
	Columns    []string `json:"columns,omitempty"` // columns involved in the check (from conkey)
	Expression string   `json:"expression"`        // full constraint def from pg_get_constraintdef, e.g. "CHECK ((age > 0))"
}

CheckConstraint describes a check constraint.

type Config added in v0.19.5

type Config struct {
	*config.Config
	Client    *api.ClientWithResponses `json:"-"`
	ProjectID string                   `json:"-"`
}

Config is a convenience wrapper around config.Config that adds an API client and the current project ID. Since most commands require all of these to function, it is often easier to load them and pass them around together. Functions that only require a config but not a client (i.e. functions that do not make any API calls) should call config.Load directly instead.

func LoadConfig added in v0.19.5

func LoadConfig(ctx context.Context) (*Config, error)

type ConnectionDetails

type ConnectionDetails struct {
	Role     string `json:"role,omitempty"`
	Password string `json:"password,omitempty"`
	Host     string `json:"host,omitempty"`
	Port     int    `json:"port,omitempty"`
	Database string `json:"database,omitempty"`
	IsPooler bool   `json:"is_pooler,omitempty"`
	// contains filtered or unexported fields
}

func GetConnectionDetails

func GetConnectionDetails(service api.Service, opts ConnectionDetailsOptions) (*ConnectionDetails, error)

func GetReplicaConnectionDetails added in v0.20.6

func GetReplicaConnectionDetails(primary api.Service, replica api.ReadReplicaSet, opts ConnectionDetailsOptions) (*ConnectionDetails, error)

GetReplicaConnectionDetails builds connection details for a read replica set. Host/port come from the replica's endpoint, but the password is looked up via the primary, since replicas share the primary's credentials.

func (*ConnectionDetails) RequirePooler added in v0.20.6

func (d *ConnectionDetails) RequirePooler(requested bool) error

RequirePooler returns an error when pooling was requested but the resolved connection isn't using the pooler endpoint. Callers that treat a missing pooler as fatal use this; the read replica path instead warns and falls back to a direct connection.

func (*ConnectionDetails) String

func (d *ConnectionDetails) String() string

String creates a PostgreSQL connection string from service details

type ConnectionDetailsOptions

type ConnectionDetailsOptions struct {
	// Pooled determines whether to use the pooler endpoint (if available)
	Pooled bool

	// Role is the database role/username to use (e.g., "tsdbadmin")
	Role string

	// WithPassword determines whether to include the password in the output
	WithPassword bool

	// InitialPassword is an optional password to use directly (e.g., from service creation response)
	// If provided and WithPassword is true, this password will be used
	// instead of fetching from password storage. This is useful when password_storage=none.
	InitialPassword string

	// ReadOnly forces the connection into Tiger Cloud's immutable read-only
	// mode by injecting the tsdb_admin.read_only_connection GUC as a startup
	// parameter. The GUC cannot be disabled with SET for the duration of the
	// session, so this is safe to use even when the LLM controls the SQL.
	ReadOnly bool
}

ConnectionDetailsOptions configures how the connection string is built

type ConstraintType added in v0.21.0

type ConstraintType string

ConstraintType represents the type of a table constraint.

const (
	ConstraintPrimaryKey ConstraintType = "PRIMARY KEY"
	ConstraintUnique     ConstraintType = "UNIQUE"
	ConstraintForeignKey ConstraintType = "FOREIGN KEY"
)

type ContinuousAggregateInfo added in v0.21.0

type ContinuousAggregateInfo struct {
	CompressionEnabled bool `json:"compression_enabled"`
	// MaterializedOnly reports whether queries against the view return only
	// already-materialized data (true) or also combine the not-yet-
	// materialized recent data in real time (false).
	MaterializedOnly bool `json:"materialized_only"`
}

ContinuousAggregateInfo describes TimescaleDB continuous aggregate metadata for a view (see ViewSchema.ContinuousAggregate).

type DatabaseSchema added in v0.21.0

type DatabaseSchema struct {
	ID      string             `json:"id"`
	Name    string             `json:"name"`
	Schemas []NamespacedSchema `json:"schemas"`
}

DatabaseSchema holds complete schema information for a database, grouped by namespace (Postgres schema).

func FetchSchemaFromConn added in v0.21.0

func FetchSchemaFromConn(ctx context.Context, conn *pgx.Conn, ident SchemaIdent, opts SchemaOptions) (*DatabaseSchema, error)

FetchSchemaFromConn introspects the schema of the database reachable over conn, scoped by opts (see SchemaOptions). ident only supplies the ID/Name shown in the result; it does not affect what is queried. The caller owns conn and is responsible for any readiness check before connecting.

func FetchServiceSchema added in v0.21.0

func FetchServiceSchema(ctx context.Context, service api.Service, role string, pooled bool, opts SchemaOptions) (*DatabaseSchema, error)

FetchServiceSchema opens a read-only connection to the service and introspects its schema. It is the shared entry point for the `tiger db schema` CLI command and the db_schema MCP tool.

The connection is forced read-only: introspection only issues SELECTs, so this is always safe and guards against accidental writes.

type DeletionWaitHandler

type DeletionWaitHandler struct {
	ServiceID string
}

func (*DeletionWaitHandler) Check

func (*DeletionWaitHandler) InitialCheck added in v0.20.0

func (h *DeletionWaitHandler) InitialCheck() (bool, error)

func (*DeletionWaitHandler) Message

func (h *DeletionWaitHandler) Message() string

type EnumSchema added in v0.21.0

type EnumSchema struct {
	Name string `json:"name"`
	// Comment is the type's COMMENT ON TYPE text. Only populated when
	// comments are requested.
	Comment string   `json:"comment,omitempty"`
	Values  []string `json:"values,omitempty"`
}

EnumSchema describes an enum type.

type ExclusionConstraint added in v0.21.0

type ExclusionConstraint struct {
	Name       string `json:"name"`
	Definition string `json:"definition"` // full constraint def from pg_get_constraintdef, e.g. "EXCLUDE USING gist (circle WITH &&)"
}

ExclusionConstraint describes an exclusion constraint.

type ExitCodeError

type ExitCodeError struct {
	// contains filtered or unexported fields
}

ExitCodeError creates an error that will cause the program to exit with the specified code

func (ExitCodeError) Error

func (e ExitCodeError) Error() string

func (ExitCodeError) ExitCode

func (e ExitCodeError) ExitCode() int

func (ExitCodeError) Unwrap added in v0.19.5

func (e ExitCodeError) Unwrap() error

type ForeignTableInfo added in v0.21.0

type ForeignTableInfo struct {
	Server  string   `json:"server"`            // pg_foreign_server.srvname
	Wrapper string   `json:"wrapper"`           // pg_foreign_data_wrapper.fdwname
	Options []string `json:"options,omitempty"` // ftoptions as "key=value" strings
}

ForeignTableInfo describes the FDW binding of a foreign table. Only table-level options (pg_foreign_table.ftoptions, e.g. schema_name / table_name for postgres_fdw) are exposed; server-level options and user mappings, which can carry credentials, are never fetched.

type HypertableInfo added in v0.21.0

type HypertableInfo struct {
	CompressionEnabled bool `json:"compression_enabled"`
	NumChunks          int  `json:"num_chunks"`
}

HypertableInfo describes TimescaleDB hypertable metadata for a table.

type IndexSchema added in v0.21.0

type IndexSchema struct {
	Name        string `json:"name"`
	Columns     string `json:"columns"` // column expressions, e.g. "status" or "created_at DESC"
	Definition  string `json:"definition,omitempty"`
	IsUnique    bool   `json:"is_unique,omitempty"`
	WhereClause string `json:"where_clause,omitempty"` // for partial indexes, empty if not partial
}

IndexSchema describes an index.

type KeyringStorage

type KeyringStorage struct{}

KeyringStorage implements password storage using system keyring

func (*KeyringStorage) Get

func (k *KeyringStorage) Get(service api.Service, role string) (string, error)

func (*KeyringStorage) GetStorageResult

func (k *KeyringStorage) GetStorageResult(err error, password string) PasswordStorageResult

func (*KeyringStorage) Remove

func (k *KeyringStorage) Remove(service api.Service, role string) error

func (*KeyringStorage) Save

func (k *KeyringStorage) Save(service api.Service, password string, role string) error

type NamespacedSchema added in v0.21.0

type NamespacedSchema struct {
	Name string `json:"name"`
	// Comment is the schema's COMMENT ON SCHEMA text. Only populated when
	// comments are requested. A schema with a comment but no visible objects
	// is not surfaced just for its comment.
	Comment           string        `json:"comment,omitempty"`
	Tables            []TableSchema `json:"tables,omitempty"`
	Views             []ViewSchema  `json:"views,omitempty"`
	MaterializedViews []ViewSchema  `json:"materialized_views,omitempty"`
	Enums             []EnumSchema  `json:"enums,omitempty"`
	Functions         []Routine     `json:"functions,omitempty"`
	Procedures        []Routine     `json:"procedures,omitempty"`
}

NamespacedSchema groups the objects belonging to a single Postgres schema.

type NoStorage

type NoStorage struct{}

NoStorage implements no password storage (passwords are not saved)

func (*NoStorage) Get

func (n *NoStorage) Get(service api.Service, role string) (string, error)

func (*NoStorage) GetStorageResult

func (n *NoStorage) GetStorageResult(err error, password string) PasswordStorageResult

func (*NoStorage) Remove

func (n *NoStorage) Remove(service api.Service, role string) error

func (*NoStorage) Save

func (n *NoStorage) Save(service api.Service, password string, role string) error

type PartitionInfo added in v0.21.0

type PartitionInfo struct {
	Name string `json:"name"`
	// Schema is the partition child's schema. It is only populated when the
	// partition lives in a different schema than its parent table (PostgreSQL
	// allows this), so that callers can schema-qualify the partition
	// correctly. When empty, the partition shares its parent's schema.
	Schema string `json:"schema,omitempty"`
	// Bound is the partition's bound expression (from pg_get_expr on
	// relpartbound), e.g. "FOR VALUES FROM ('2024-01-01') TO ('2025-01-01')".
	Bound string `json:"bound,omitempty"`
}

PartitionInfo describes a single child partition of a partitioned table.

type PasswordStorage

type PasswordStorage interface {
	Save(service api.Service, password string, role string) error
	Get(service api.Service, role string) (string, error)
	Remove(service api.Service, role string) error
	GetStorageResult(err error, password string) PasswordStorageResult
}

PasswordStorage defines the interface for password storage implementations

func GetPasswordStorage

func GetPasswordStorage() PasswordStorage

GetPasswordStorage returns the appropriate PasswordStorage implementation based on configuration

type PasswordStorageResult

type PasswordStorageResult struct {
	Success bool   `json:"success"`
	Method  string `json:"method"`  // "keyring", "pgpass", or "none"
	Message string `json:"message"` // Human-readable message
}

PasswordStorageResult contains the result of password storage operations

func SavePasswordWithResult

func SavePasswordWithResult(service api.Service, password string, role string) (PasswordStorageResult, error)

SavePasswordWithResult handles saving a password and returns both error and result info

type PgpassStorage

type PgpassStorage struct{}

PgpassStorage implements password storage using ~/.pgpass file

func (*PgpassStorage) Get

func (p *PgpassStorage) Get(service api.Service, role string) (string, error)

func (*PgpassStorage) GetStorageResult

func (p *PgpassStorage) GetStorageResult(err error, password string) PasswordStorageResult

func (*PgpassStorage) Remove

func (p *PgpassStorage) Remove(service api.Service, role string) error

func (*PgpassStorage) Save

func (p *PgpassStorage) Save(service api.Service, password string, role string) error

type Routine added in v0.21.0

type Routine struct {
	Name string `json:"name"`
	// Arguments is the identity argument list (e.g. "integer, text"),
	// which distinguishes overloaded routines that share a name. Empty for
	// a routine that takes no arguments.
	Arguments string      `json:"arguments,omitempty"`
	Type      RoutineType `json:"type"`
	// Comment is the routine's COMMENT ON FUNCTION/PROCEDURE text. Only
	// populated when comments are requested.
	Comment    string `json:"comment,omitempty"`
	Definition string `json:"definition,omitempty"`
}

Routine describes a function or procedure.

type RoutineType added in v0.21.0

type RoutineType string

RoutineType is the type of a routine.

const (
	RoutineFunction  RoutineType = "FUNCTION"
	RoutineProcedure RoutineType = "PROCEDURE"
)

type SchemaIdent added in v0.21.0

type SchemaIdent struct {
	ID   string
	Name string
}

SchemaIdent identifies the service whose schema was fetched. Its values populate DatabaseSchema.ID and DatabaseSchema.Name for display.

type SchemaNotFoundError added in v0.21.0

type SchemaNotFoundError struct {
	// Schema is the requested namespace that was not found.
	Schema string
	// Available lists the schemas the connecting user can access (i.e. holds
	// USAGE on), minus the internal namespaces a default browse hides unless
	// --internal is set. It is a best-effort suggestion list, not a guarantee
	// that each schema would produce non-empty results (a schema whose
	// contents are entirely extension-owned still renders empty on a default
	// browse). It is nil when enumeration failed (in which case ListErr is
	// set).
	Available []string
	// ListErr is non-nil when listing the available schemas failed.
	ListErr error
}

SchemaNotFoundError indicates the requested namespace does not exist. It carries a friendly message listing the available schemas when they could be enumerated. Callers can detect it with errors.As to distinguish a mistyped schema (a client input error) from an upstream/connection failure.

func (*SchemaNotFoundError) Error added in v0.21.0

func (e *SchemaNotFoundError) Error() string

Error implements the error interface.

func (*SchemaNotFoundError) Unwrap added in v0.21.0

func (e *SchemaNotFoundError) Unwrap() error

Unwrap exposes the underlying listing error (if any) for errors.Is/As.

type SchemaOptions added in v0.21.0

type SchemaOptions struct {
	// Schema, if non-empty, limits the fetch to a single namespace.
	Schema string
	// IncludeInternal disables the exclusion filters, adding catalog (pg_*)
	// and extension-owned objects.
	IncludeInternal bool
	// IncludeDefinitions fetches full object definitions (view SELECTs and
	// routine bodies), omitted by default since they can be large and may
	// embed secrets.
	IncludeDefinitions bool
	// IncludeComments fetches object comments (COMMENT ON text), omitted by
	// default to keep the output concise.
	IncludeComments bool
}

SchemaOptions controls what FetchSchemaFromConn collects.

type Spinner

type Spinner interface {
	// Update changes the spinner's displayed message.
	Update(message string)

	// Stop terminates the spinner program and waits for it to finish.
	Stop()
}

func NewSpinner

func NewSpinner(output io.Writer, message string) Spinner

NewSpinner creates and returns a new Spinner for displaying animated status messages. If the output is nil or io.Discard, it returns a no-op spinner. If output is a terminal, it uses bubbletea to dynamically update the spinner and message in place. If output is not a terminal, it prints each message on a new line without animation.

type StatusWaitHandler

type StatusWaitHandler struct {
	TargetStatus string
	Service      *api.Service
}

func (*StatusWaitHandler) Check

func (h *StatusWaitHandler) Check(resp *api.GetServiceResponse) (bool, error)

func (*StatusWaitHandler) InitialCheck added in v0.20.0

func (h *StatusWaitHandler) InitialCheck() (bool, error)

func (*StatusWaitHandler) Message

func (h *StatusWaitHandler) Message() string

type TableColumnSchema added in v0.21.0

type TableColumnSchema struct {
	Name string `json:"name"`
	Type string `json:"type"`
	// Comment is the column's COMMENT ON COLUMN text. Only populated when
	// comments are requested.
	Comment      string `json:"comment,omitempty"`
	NotNull      bool   `json:"not_null,omitempty"`
	Default      string `json:"default,omitempty"`       // empty if no default
	IsSerial     bool   `json:"is_serial,omitempty"`     // true if SERIAL/BIGSERIAL/SMALLSERIAL (has sequence, not identity)
	IdentityType string `json:"identity_type,omitempty"` // 'a' = ALWAYS, 'd' = BY DEFAULT, ” = not identity
}

TableColumnSchema holds schema information for a table column.

type TableConstraint added in v0.21.0

type TableConstraint struct {
	Type       ConstraintType `json:"type"`
	Name       string         `json:"name"`
	Columns    []string       `json:"columns,omitempty"`
	RefTable   string         `json:"ref_table,omitempty"`   // for FK
	RefColumns []string       `json:"ref_columns,omitempty"` // for FK
}

TableConstraint describes a constraint (single or multi-column).

type TableSchema added in v0.21.0

type TableSchema struct {
	Name string `json:"name"`
	// Comment is the table's COMMENT ON TABLE text. Only populated when
	// comments are requested.
	Comment     string                `json:"comment,omitempty"`
	Columns     []TableColumnSchema   `json:"columns,omitempty"`
	Constraints []TableConstraint     `json:"constraints,omitempty"` // PK, UK, FK constraints (single and multi-column)
	Indexes     []IndexSchema         `json:"indexes,omitempty"`
	Checks      []CheckConstraint     `json:"checks,omitempty"`
	Exclusions  []ExclusionConstraint `json:"exclusions,omitempty"`
	Triggers    []TriggerSchema       `json:"triggers,omitempty"`
	// Partitions lists the direct child partitions of a partitioned table.
	// Only populated for partitioned tables (relkind 'p'). Leaf partitions
	// are normally hidden as standalone tables, but in a multi-level hierarchy
	// an intermediate partitioned table is shown both as an entry here (under
	// its parent) and as its own table carrying its sub-partitions. When a
	// single schema is requested, a leaf whose parent lives in a different
	// schema is shown as a standalone table instead (see leafPartitionExclusion).
	Partitions []PartitionInfo `json:"partitions,omitempty"`
	Hypertable *HypertableInfo `json:"hypertable,omitempty"`
	// Foreign is the FDW binding of a foreign table (relkind 'f'). Nil for
	// regular tables. Foreign tables are modeled as tables because they
	// behave like them (columns, CHECK constraints, triggers, partition
	// membership); this field is what distinguishes them.
	Foreign *ForeignTableInfo `json:"foreign,omitempty"`
}

TableSchema holds schema information for a table.

type TriggerSchema added in v0.21.0

type TriggerSchema struct {
	Name         string `json:"name"`
	Timing       string `json:"timing"`
	Manipulation string `json:"manipulation"`
	Statement    string `json:"statement"`
}

TriggerSchema describes a single trigger on a table.

type ViewColumnSchema added in v0.21.0

type ViewColumnSchema struct {
	Name string `json:"name"`
	Type string `json:"type"`
	// Comment is the column's COMMENT ON COLUMN text. Only populated when
	// comments are requested.
	Comment string `json:"comment,omitempty"`
}

ViewColumnSchema holds column info for views (simpler than table columns).

type ViewSchema added in v0.21.0

type ViewSchema struct {
	Name string `json:"name"`
	// Comment is the view's COMMENT ON (MATERIALIZED) VIEW text. Only
	// populated when comments are requested.
	Comment string             `json:"comment,omitempty"`
	Columns []ViewColumnSchema `json:"columns,omitempty"`
	// Definition is the view's defining SELECT (from pg_get_viewdef).
	Definition string `json:"definition,omitempty"`
	// Indexes are only populated for materialized views.
	Indexes []IndexSchema `json:"indexes,omitempty"`
	// Triggers lists triggers defined on the view (e.g. INSTEAD OF
	// triggers on a regular view). Not applicable to materialized views.
	Triggers []TriggerSchema `json:"triggers,omitempty"`
	// ContinuousAggregate is TimescaleDB continuous aggregate metadata. Nil
	// for ordinary views. A continuous aggregate is a regular view (relkind
	// 'v') over an internal materialization hypertable, so it appears under
	// Views; this field is what distinguishes it. When set and definitions
	// were requested, Definition holds the user's original defining query
	// rather than the rewritten SELECT over the internal materialization
	// hypertable that pg_get_viewdef returns.
	ContinuousAggregate *ContinuousAggregateInfo `json:"continuous_aggregate,omitempty"`
}

ViewSchema holds schema information for a view or materialized view.

type WaitForServiceArgs

type WaitForServiceArgs struct {
	Client     *api.ClientWithResponses
	ProjectID  string
	ServiceID  string
	Handler    WaitHandler
	Output     io.Writer
	Timeout    time.Duration
	TimeoutMsg string
}

type WaitHandler

type WaitHandler interface {
	// Message returns the current status message that should be displayed next
	// to the spinner while waiting for a service to reach some state.
	Message() string

	// InitialCheck returns true if we don't need to begin the waiting/polling
	// process, and false if we should.  It also returns an error, which is
	// either immediately returned from WaitForService or temporarily shown
	// next to the spinner depending on the first return value.
	InitialCheck() (bool, error)

	// Check returns true if we're done waiting/polling, and false if we should
	// continue. It also returns an error, which is either immediately returned
	// from WaitForService or temporarily shown next to the spinner depending
	// on the first return value.
	Check(resp *api.GetServiceResponse) (bool, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL