diff

package
v1.67.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

type DomainDiffResult struct {
	Stmts               []string
	DropStmts           []string
	DisallowedDropStmts []string
}

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

type DropChecker interface {
	IsDropAllowed(objectType string) bool
}

DropChecker checks whether dropping a specific object type is allowed.

type EnumDiffResult added in v0.9.0

type EnumDiffResult struct {
	Stmts               []string
	DropStmts           []string
	DisallowedDropStmts []string
}

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

type RetypedColumn struct {
	Name    string
	Current string
}

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
	// 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

type SequenceDiffResult struct {
	Stmts               []string
	DropStmts           []string
	DisallowedDropStmts []string
}

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL