Documentation
¶
Index ¶
- type ApplyOptions
- type Client
- func (client *Client) Apply(ctx context.Context, options *ApplyOptions, w io.Writer) (*ObjectCount, error)
- func (client *Client) Dump(ctx context.Context, options *DumpOptions) (*DumpResult, error)
- func (client *Client) Format(options *FmtOptions) (map[string]string, error)
- func (client *Client) Plan(ctx context.Context, options *PlanOptions) (*PlanResult, error)
- type DropPolicy
- type DumpOptions
- type DumpResult
- type FilterOptions
- type FmtOptions
- 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:"PIST_PRE_SQL" help:"SQL to execute before applying changes."`
PreSQLFile string `type:"path" xor:"pre-sql" env:"PIST_PRE_SQL_FILE" help:"Path to a SQL file to execute before applying changes."`
WithTx bool `help:"Execute the pre-SQL and schema changes in a transaction."`
IndexConcurrently bool `env:"PIST_INDEX_CONCURRENTLY" help:"Use CREATE/DROP INDEX CONCURRENTLY for index operations."`
}
type Client ¶
type Client struct {
*Options
}
func (*Client) Apply ¶
func (client *Client) Apply(ctx context.Context, options *ApplyOptions, w io.Writer) (*ObjectCount, error)
func (*Client) Dump ¶
func (client *Client) Dump(ctx context.Context, options *DumpOptions) (*DumpResult, error)
func (*Client) Format ¶ added in v0.11.0
func (client *Client) Format(options *FmtOptions) (map[string]string, error)
Format formats SQL files and returns the results. Each file is formatted independently and returned as a map from file path to formatted SQL.
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 `` /* 156-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 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
}
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" help:"Include only tables/views/enums/domains matching the pattern (wildcard: *, ?)."`
Exclude []string `short:"E" help:"Exclude tables/views/enums/domains matching the pattern (wildcard: *, ?)."`
Enable []string `enum:"table,view,enum,domain" env:"PIST_ENABLE" help:"Enable only specified object types (can be repeated)."`
Disable []string `enum:"table,view,enum,domain" env:"PIST_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 FmtOptions ¶ added in v0.11.0
type FmtOptions struct {
Files []string `arg:"" help:"Path to the SQL file(s) to format."`
Write bool `short:"w" xor:"mode" help:"Write result to source file(s) instead of stdout."`
Check bool `xor:"mode" help:"Check if files are formatted. Exit with non-zero status if any file needs formatting."`
}
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 `` /* 195-byte string literal not displayed */
Password string `env:"PIST_PASSWORD" help:"PostgreSQL password."`
Schemas []string `short:"n" env:"PIST_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:"PIST_PRE_SQL" help:"SQL to prepend to the plan output."`
PreSQLFile string `type:"path" xor:"pre-sql" env:"PIST_PRE_SQL_FILE" help:"Path to a SQL file to prepend to the plan output."`
IndexConcurrently bool `env:"PIST_INDEX_CONCURRENTLY" help:"Use CREATE/DROP INDEX CONCURRENTLY for index operations."`
}
type PlanResult ¶ added in v0.15.0
type PlanResult struct {
SQL string
Count ObjectCount
}
PlanResult holds the result of a Plan operation.