Documentation
¶
Index ¶
- type ApplyOptions
- type ApplyResult
- type Client
- func (client *Client) Apply(ctx context.Context, options *ApplyOptions, w io.Writer) (*ApplyResult, error)
- func (client *Client) ConnInfoComment() (string, error)
- func (client *Client) Dump(ctx context.Context, options *DumpOptions) (*DumpResult, error)
- func (client *Client) Plan(ctx context.Context, options *PlanOptions) (*PlanResult, error)
- type DropPolicy
- type DumpOptions
- type DumpResult
- type FilterOptions
- type ObjectCount
- type Options
- type PlanOptions
- type PlanResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyOptions ¶
type ApplyOptions struct {
FilterOptions
DropPolicy
Files []string `arg:"" help:"Path to the desired schema SQL file(s)."`
PreSQL string `xor:"pre-sql" env:"PISTA_PRE_SQL" help:"SQL to execute before applying changes."`
PreSQLFile string `type:"path" xor:"pre-sql" env:"PISTA_PRE_SQL_FILE" help:"Path to a SQL file to execute before applying changes."`
ConcurrentlyPreSQL string `` /* 218-byte string literal not displayed */
ConcurrentlyPreSQLFile string `` /* 144-byte string literal not displayed */
WithTx bool `xor:"tx-mode" env:"PISTA_WITH_TX" help:"Execute pre-SQL and schema changes in a transaction."`
DisableIndexConcurrently bool `` /* 155-byte string literal not displayed */
ForceIndexConcurrently bool `` /* 180-byte string literal not displayed */
BulkAlter bool `` /* 199-byte string literal not displayed */
}
type ApplyResult ¶ added in v0.23.3
type ApplyResult struct {
Count ObjectCount
DisallowedDrops string
// Applied reports whether any schema change was actually applied: schema
// DDL or an executed -- pista:execute statement. Pre-SQL,
// concurrently-pre-SQL, transaction control, search_path setup, and
// -- pista:execute directives skipped by their check SQL do not count.
Applied bool
// Duration is the elapsed time of the apply phase: every statement sent to
// the database (transaction BEGIN/COMMIT, pre-SQL, schema DDL, search_path
// setup, -- pista:execute check SQL, and execute statements) plus the time
// writing them to the output writer. It excludes connection setup and diff
// computation, and is zero unless Applied is true. With a fast writer it is
// dominated by database execution time.
Duration time.Duration
}
ApplyResult holds the result of an Apply operation.
type Client ¶
type Client struct {
*Options
}
func (*Client) Apply ¶
func (client *Client) Apply(ctx context.Context, options *ApplyOptions, w io.Writer) (*ApplyResult, error)
func (*Client) ConnInfoComment ¶ added in v1.7.3
ConnInfoComment returns a SQL comment describing the connection target (host/port/dbname/user) for inclusion at the top of plan/apply/dump output. The password is intentionally never included.
TCP connections render as a libpq URI (postgres://user@host:port/dbname). IPv6 hosts are bracketed via net.JoinHostPort; user and dbname are URL-escaped via net/url so identifiers with URI-meaningful characters (including '/' in the dbname) round-trip safely; Path holds the decoded form and RawPath the encoded form, so url.URL.String() uses RawPath when the default encoding would differ. libpq unix-socket connections (host starts with "/") render as a keyword/value string ("host=/path dbname=db user=u") instead; percent-encoding the socket path into the URI host component would be unreadable in a comment.
func (*Client) Dump ¶
func (client *Client) Dump(ctx context.Context, options *DumpOptions) (*DumpResult, error)
func (*Client) Plan ¶
func (client *Client) Plan(ctx context.Context, options *PlanOptions) (*PlanResult, error)
type DropPolicy ¶ added in v0.14.0
type DropPolicy struct {
AllowDrop []string `` /* 179-byte string literal not displayed */
}
DropPolicy controls which object types are allowed to be dropped. If AllowDrop is empty, no drops are allowed (safe default). If AllowDrop contains "all", all drops are allowed. Otherwise, only the listed object types are allowed to be dropped.
func (*DropPolicy) IsDropAllowed ¶ added in v0.14.0
func (p *DropPolicy) IsDropAllowed(objectType string) bool
type DumpOptions ¶
type DumpOptions struct {
FilterOptions
Split string `help:"Output each table/view/enum/domain as a separate file in the specified directory."`
OmitSchema bool `help:"Omit schema name from the dump output."`
}
type DumpResult ¶ added in v0.3.0
type DumpResult struct {
Tables *orderedmap.Map[string, *model.Table]
Views *orderedmap.Map[string, *model.View]
Enums *orderedmap.Map[string, *model.Enum]
Domains *orderedmap.Map[string, *model.Domain]
OmitSchema bool
Count ObjectCount
}
func (*DumpResult) Files ¶ added in v0.3.0
func (r *DumpResult) Files() map[string]string
func (*DumpResult) String ¶ added in v0.3.0
func (r *DumpResult) String() string
type FilterOptions ¶ added in v0.11.0
type FilterOptions struct {
Include []string `short:"I" env:"PISTA_INCLUDE" help:"Include only tables/views/enums/domains matching the pattern (wildcard: *, ?)."`
Exclude []string `short:"E" env:"PISTA_EXCLUDE" help:"Exclude tables/views/enums/domains matching the pattern (wildcard: *, ?)."`
Enable []string `enum:"table,view,enum,domain" env:"PISTA_ENABLE" help:"Enable only specified object types (can be repeated)."`
Disable []string `enum:"table,view,enum,domain" env:"PISTA_DISABLE" help:"Disable specified object types (can be repeated)."`
}
func (*FilterOptions) AfterApply ¶ added in v0.11.0
func (f *FilterOptions) AfterApply() error
func (*FilterOptions) IsTypeEnabled ¶ added in v0.12.0
func (f *FilterOptions) IsTypeEnabled(typeName string) bool
IsTypeEnabled returns true if the given object type should be included. Enable takes precedence: if set, only listed types are enabled. Disable excludes listed types (ignored when Enable is set). If neither is set, all types are enabled.
func (*FilterOptions) MatchName ¶ added in v0.11.0
func (f *FilterOptions) MatchName(name string) bool
func (*FilterOptions) ValidatePatterns ¶ added in v0.11.0
func (f *FilterOptions) ValidatePatterns() error
type ObjectCount ¶ added in v0.15.0
ObjectCount holds the number of objects inspected by type.
func (ObjectCount) SchemaLabel ¶ added in v0.17.2
func (c ObjectCount) SchemaLabel() string
func (ObjectCount) Summary ¶ added in v0.17.2
func (c ObjectCount) Summary() string
type Options ¶
type Options struct {
ConnString string `` /* 196-byte string literal not displayed */
DBName string `name:"dbname" short:"d" env:"PISTA_DBNAME" help:"PostgreSQL database name. Overrides the dbname in --conn-string."`
Password string `env:"PISTA_PASSWORD" help:"PostgreSQL password."`
Schemas []string `short:"n" env:"PISTA_SCHEMAS" default:"public" help:"Schemas to inspect and modify."`
SchemaMap map[string]string `short:"m" help:"Schema name mapping (e.g. -m old=new)."`
}
func (*Options) AfterApply ¶ added in v0.4.0
func (*Options) RemapSchema ¶ added in v0.4.0
func (*Options) ReverseRemapSchema ¶ added in v0.4.0
func (*Options) ValidateSchemaMap ¶ added in v0.4.0
type PlanOptions ¶
type PlanOptions struct {
FilterOptions
DropPolicy
Files []string `arg:"" help:"Path to the desired schema SQL file(s)."`
PreSQL string `xor:"pre-sql" env:"PISTA_PRE_SQL" help:"SQL to prepend to the plan output."`
PreSQLFile string `type:"path" xor:"pre-sql" env:"PISTA_PRE_SQL_FILE" help:"Path to a SQL file to prepend to the plan output."`
ConcurrentlyPreSQL string `` /* 192-byte string literal not displayed */
ConcurrentlyPreSQLFile string `` /* 140-byte string literal not displayed */
DisableIndexConcurrently bool `` /* 155-byte string literal not displayed */
ForceIndexConcurrently bool `` /* 137-byte string literal not displayed */
BulkAlter bool `` /* 199-byte string literal not displayed */
}
type PlanResult ¶ added in v0.15.0
type PlanResult struct {
SQL string
DisallowedDrops string
Count ObjectCount
// HasChanges is true when the plan contains executable statements
// (DDL or execute directives). Suppressed drops do not count.
HasChanges bool
}
PlanResult holds the result of a Plan operation.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pista
command
|
|
|
internal
|
|
|
pgast
Package pgast provides shared pg_query AST helpers used by both the rename rewriter (diff package) and the column-reference validator (parser package).
|
Package pgast provides shared pg_query AST helpers used by both the rename rewriter (diff package) and the column-reference validator (parser package). |