Documentation
¶
Overview ¶
Package diff compares two schemas object by object and lists what it takes to turn one into the other. It reads what the loader holds of the database state and nothing else: `-- sqlshape:` directives, problems and analysis results are not schema.
Expressions compare by their deparsed text, so the two sides should be in the same form: both loaded from schema text, or both canonical (dump.Canonical / dump.Load). A rename is not recognized: it shows as a drop and an add, and an intent declaration is the place to say otherwise.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Props ¶
Props are the comparable properties of a relation, column, constraint, index, rule, function or trigger: two objects with equal Props are the same to Compare.
Types ¶
type Change ¶
type Change struct {
Op Op
Kind string // schema, extension, enum, domain, composite, range, table, view, matview, sequence, column, constraint, index, rule, policy, rows, function, trigger, comment
Name string // qualified as the loader prints it: public omitted; column / constraint / index / rule as <relation>.<name>; trigger as <relation>.<name>
// Fields are the properties that differ, for Alter.
Fields []Field
}
Change is one object added, dropped or altered.
func Compare ¶
Compare lists the changes from a to b, sorted by kind order (dependencies first for additions: schemas, extensions, types, relations, their parts, functions, triggers, comments) then by name. Drops come in the same order; ordering for execution is the DDL generator's job.
type Field ¶
Field is one differing property.
func RowChanges ¶
RowChanges compares the seeded content of a table: the rows the target declares against the rows the source holds, by key. Each field names the key and shows the row texts (From empty for a row to insert, To empty for one to delete). A column left out of the declaration does not count, rows an additive seed does not list are not a change, and a target without a seed declares nothing about the content.