Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDiffChanges = errors.New("diff contains changes")
ErrDiffChanges is returned by Diff.Run when --check is set and the diff contains executable DDL. main maps it to exit code 2. Suppressed drops alone do not trigger it.
var ErrFormatDiff = errors.New("files need formatting")
ErrFormatDiff is returned by Fmt.Run when --check is set and a file is not formatted. main maps it to exit code 2, the same as plan --check.
var ErrPlanDiff = errors.New("plan contains changes")
ErrPlanDiff is returned by Plan.Run when --check is set and the plan contains executable DDL. main maps it to exit code 2. Suppressed drops alone do not trigger it.
Functions ¶
func StartPager ¶ added in v1.9.1
StartPager wraps w with a pager subprocess when all of the following hold:
- paging hasn't been disabled by --no-pager (pager != nil && *pager == false),
- either pager was explicitly forced via --pager (*pager == true) or w is a TTY (so the user is actually viewing the output interactively),
- PISTA_PAGER is set to a non-empty command line.
pager == nil means the user passed neither --pager nor --no-pager, so the TTY check decides. Otherwise *pager explicitly turns paging on or off, but an unset PISTA_PAGER still gates everything (matching the convention that the env var is the source of truth for *which* pager to run).
Otherwise it returns w unchanged with a no-op close. The returned close function tears down the pager and waits for it to exit, so callers should always invoke it (typically via defer).
Types ¶
type ApplyFrom ¶ added in v1.60.0
type ApplyFrom struct {
pistachio.ConnOptions
pistachio.ApplyFromOptions
}
ApplyFrom takes the connection and the flags that decide how the statements are run. Everything that decides what is read or what is run comes from the plan file, so those flags are not offered here: one given on the command line would either be ignored or turn the plan file's own scope into drift.
type Diff ¶ added in v1.54.0
type Diff struct {
// Schemas is the one connection option diff reads. No database is opened,
// but the parser qualifies an unqualified name with the first entry, and
// only objects in these schemas are compared, the same way plan reads the
// catalog.
Schemas []string `short:"n" env:"PISTA_SCHEMAS" default:"public" help:"Schemas to compare. Unqualified names are qualified with the first."`
pistachio.DiffOptions
Check bool `env:"PISTA_CHECK" help:"Exit with code 2 when the diff contains executable changes."`
}
func (*Diff) AfterApply ¶ added in v1.59.0
AfterApply trims each schema name the way the global option does.
type Fmt ¶ added in v0.11.0
type Parse ¶ added in v1.51.0
type Parse struct {
Files []string `arg:"" help:"Path to the schema SQL file(s)."`
// Schemas is the one connection option parse reads. No database is opened,
// but the parser qualifies an unqualified name with the first entry, the
// same way plan and apply read their input.
Schemas []string `short:"n" env:"PISTA_SCHEMAS" default:"public" help:"Schema to qualify unqualified names with. Only the first is used."`
}
func (*Parse) AfterApply ¶ added in v1.59.0
AfterApply trims each schema name the way the global option does.