Documentation
¶
Overview ¶
Package compare diffs the schemas of two live connections and turns a reviewed selection of the differences into an applyable patch. Every comparison and patch is one tracked run, recorded to history with its result.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SchemaSummary ¶
SchemaSummary counts a SQL Server migration snapshot's objects by kind.
Types ¶
type Object ¶
type Object struct {
Kind string `json:"kind"`
Name migrate.Name `json:"name"`
Status string `json:"status"`
Before string `json:"before,omitempty"`
After string `json:"after,omitempty"`
Language string `json:"language"`
Changes []string `json:"changes"`
}
Object is one changed schema object with its definition on each side: module SQL, a JSON table snapshot (SQL Server) or an HCL block (Postgres, SQLite). Before is empty for an added object and After for a deleted one.
type Options ¶
type Options struct {
Reference string `json:"reference"`
Target string `json:"target"`
Schemas []string `json:"schemas,omitempty"`
// Run names this run: its clicky group id and its history record id.
Run string `json:"run"`
// ConnectionsDir resolves connection:// references.
ConnectionsDir string `json:"-"`
// History records the run and its result.
History *history.Store `json:"-"`
}
Options names the two sides. Reference is the desired schema; Target is the database the patch brings in line with it.
type Patch ¶
type Patch struct {
Dialect string `json:"dialect"`
Artifact json.RawMessage `json:"artifact"`
SQL string `json:"sql"`
Hash string `json:"hash"`
Acks []string `json:"acks"`
Selection []string `json:"selection"`
}
func BuildPatch ¶
func BuildPatch(ctx context.Context, opts PatchOptions) (Patch, error)
BuildPatch re-inspects both sides, refuses when the differences changed since they were reviewed, and plans only the selected changes.
type PatchOptions ¶
type Result ¶
type Result struct {
Dialect string `json:"dialect"`
Reference string `json:"reference"`
Target string `json:"target"`
Schemas []string `json:"schemas"`
Changes []migrate.Change `json:"changes"`
Steps []Step `json:"steps"`
Objects []Object `json:"objects"`
// DiffHash binds a patch to the exact differences that were reviewed.
DiffHash string `json:"diffHash"`
}