Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPartitionIndexCopy ¶ added in v1.72.0
IsPartitionIndexCopy reports whether idx, an index of a partition, is the copy PostgreSQL makes of parentIdx, an index of its parent: it carries the name PostgreSQL gives the copy, and it indexes what parentIdx does, the storage parameters included. The two are compared with the index name and the table of idx replaced by those of parentIdx.
Types ¶
type CompositeTypeDiffResult ¶ added in v1.20.0
type CompositeTypeDiffResult struct {
Stmts []string
DropStmts []string
DisallowedDropStmts []string
}
func DiffCompositeTypes ¶ added in v1.20.0
func DiffCompositeTypes(current, desired *orderedmap.Map[string, *model.CompositeType], dc DropChecker) (*CompositeTypeDiffResult, error)
type DomainDiffResult ¶ added in v0.12.0
func DiffDomains ¶ added in v0.12.0
func DiffDomains(current, desired *orderedmap.Map[string, *model.Domain], dc DropChecker) (*DomainDiffResult, error)
type DropChecker ¶ added in v0.14.0
DropChecker checks whether dropping a specific object type is allowed.
type EnumDiffResult ¶ added in v0.9.0
func DiffEnums ¶ added in v0.9.0
func DiffEnums(current, desired *orderedmap.Map[string, *model.Enum], dc DropChecker) (*EnumDiffResult, error)
type RetypedColumn ¶ added in v1.66.0
RetypedColumn is a column that goes out as SET DATA TYPE. Name is <table>.<column> as the desired schema names it, and Current as the catalog names it, before any rename in the plan.
type RoutineDiffResult ¶ added in v1.30.0
type RoutineDiffResult struct {
Stmts []string
DropStmts []string
DisallowedDropStmts []string
// AtomicStmts and AtomicDropStmts hold the statements for a routine with a
// SQL-standard body, which PostgreSQL parses at creation time. They run
// with the views: the creates once the tables exist, the drops before the
// tables change. A modified routine goes by its desired form, a dropped
// one by its current form.
AtomicStmts []string
AtomicDropStmts []string
// DroppedAtomic names the routines AtomicDropStmts drops the way
// PostgreSQL names a dependent, such as "function public.f(integer)".
// They are dropped with the views, before anything they could block. A
// recreated routine whose current body is SQL-standard is dropped there
// too. A recreated routine is created again by the list its desired form
// goes to, whichever list its DROP went to.
DroppedAtomic []string
// Recreated lists the current routines that Stmts drops and creates again.
Recreated []*model.Routine
}
func DiffRoutines ¶ added in v1.30.0
func DiffRoutines(current, desired *orderedmap.Map[string, *model.Routine], dc DropChecker) (*RoutineDiffResult, error)
DiffRoutines compares functions and procedures. Both maps are keyed by FQRN, which carries the identity argument types, so an overload set appears as several independent objects and a change to an argument type reads as a drop plus a create rather than a modification.
type SequenceDiffResult ¶ added in v1.17.0
func DiffSequences ¶ added in v1.17.0
func DiffSequences(current, desired *orderedmap.Map[string, *model.Sequence], dc DropChecker) (*SequenceDiffResult, error)
type TableDiffResult ¶ added in v0.16.0
type TableDiffResult struct {
FKDropStmts []string // FK drops (should run first)
// PersistenceStmts holds the logged <-> unlogged transitions, already in an
// order PostgreSQL accepts. They are kept out of Stmts because the caller
// sorts that by object dependency, which is the right order for one
// direction and the wrong one for the other.
PersistenceStmts []string
Stmts []string // CREATE/ALTER TABLE, columns, constraints, indexes, comments
FKAddStmts []string // FK adds and renames (should run last)
// PolicyStmts holds a new table's policies. They run after every table and
// view, since a policy can read any of them. An existing table's policies
// stay in Stmts, next to its RLS change, so a live table is never left
// without them or without its RLS.
PolicyStmts []string
// PartitionedIndexStmts holds the CREATE INDEX and COMMENT ON INDEX for
// indexes on partitioned tables, deepest level first. They run after the
// tables and the partitions' own indexes, so each index attaches the
// partitions' matching indexes instead of creating copies.
PartitionedIndexStmts []string
// RetypedColumns lists the columns of existing tables that go out as SET
// DATA TYPE.
RetypedColumns []RetypedColumn
DropStmts []string // DROP TABLE (separate from Stmts for ordering)
DisallowedDropStmts []string // DROP TABLE / DROP COLUMN / DROP CONSTRAINT (incl. FK) / DROP INDEX suppressed by DropChecker, with "-- skipped: " prefix
HasConcurrently bool // true if any index operation uses CONCURRENTLY
}
TableDiffResult separates FK operations from other statements to allow correct ordering: FK drops first, then schema changes, then FK adds last.
func DiffTables ¶
func DiffTables(current, desired *orderedmap.Map[string, *model.Table], dc DropChecker) (*TableDiffResult, error)
type ViewDiffResult ¶ added in v0.18.0
type ViewDiffResult struct {
DropStmts []string // DROP VIEW / DROP MATERIALIZED VIEW (should run before table changes)
CreateStmts []string // ALTER VIEW RENAME, CREATE OR REPLACE VIEW, CREATE MATERIALIZED VIEW, indexes, comments (should run after table changes)
DisallowedDropStmts []string // DROP VIEW / DROP MATERIALIZED VIEW / DROP INDEX (on matview) suppressed by DropChecker, with "-- skipped: " prefix
HasConcurrently bool // true if any index operation uses CONCURRENTLY
// DroppedViews names every view and materialized view DropStmts drops,
// including the ones dropped to be created again. A suppressed drop is
// left out, since nothing runs. PostgreSQL refuses to drop a relation
// another object reads, so the caller checks these against the catalog;
// see checkViewDependents.
DroppedViews []string
}
ViewDiffResult separates view DROP and CREATE/MODIFY statements. Drops should run before table changes, creates after.
func DiffViews ¶
func DiffViews(current, desired *orderedmap.Map[string, *model.View], dc DropChecker) (*ViewDiffResult, error)