differ

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreDefaultsEqual

func AreDefaultsEqual(default1, default2 string) bool

func FindCycle

func FindCycle[T CycleNode](
	remaining []T,
	graph CycleGraph[T],
) string

func FunctionKey

func FunctionKey(schema, name string, argTypes []string) string

func IndexKey

func IndexKey(schema, name string) string

func IndexUsesColumn added in v0.8.25

func IndexUsesColumn(idx *schema.Index, tableName, columnName string) bool

IndexUsesColumn reports whether an index references a table column in its key expressions, included columns, or partial-index predicate.

func NewViewNormalizer

func NewViewNormalizer() *viewNormalizer

func NormalizeDataType

func NormalizeDataType(dataType string) string

func NormalizeViewDefinition

func NormalizeViewDefinition(definition string) string

func PartitionKey added in v0.3.0

func PartitionKey(tableSchema, tableName, partitionName string) string

func TableKey

func TableKey(schema, name string) string

func ViewKey

func ViewKey(schema, name string) string

Types

type Change

type Change struct {
	Type        ChangeType
	Severity    ChangeSeverity
	Description string
	ObjectType  string
	ObjectName  string
	Details     map[string]any
	DependsOn   []string
	Order       int
}

func (*Change) String

func (c *Change) String() string

type ChangeSeverity

type ChangeSeverity string
const (
	SeveritySafe                  ChangeSeverity = "SAFE"
	SeverityPotentiallyBreaking   ChangeSeverity = "POTENTIALLY_BREAKING"
	SeverityBreaking              ChangeSeverity = "BREAKING"
	SeverityDataMigrationRequired ChangeSeverity = "DATA_MIGRATION_REQUIRED"
)

type ChangeType

type ChangeType string
const (
	ChangeTypeAddSchema                 ChangeType = "ADD_SCHEMA"
	ChangeTypeDropSchema                ChangeType = "DROP_SCHEMA"
	ChangeTypeAddTable                  ChangeType = "ADD_TABLE"
	ChangeTypeDropTable                 ChangeType = "DROP_TABLE"
	ChangeTypeModifyTableComment        ChangeType = "MODIFY_TABLE_COMMENT"
	ChangeTypeAddView                   ChangeType = "ADD_VIEW"
	ChangeTypeDropView                  ChangeType = "DROP_VIEW"
	ChangeTypeModifyView                ChangeType = "MODIFY_VIEW"
	ChangeTypeAddMaterializedView       ChangeType = "ADD_MATERIALIZED_VIEW"
	ChangeTypeDropMaterializedView      ChangeType = "DROP_MATERIALIZED_VIEW"
	ChangeTypeModifyMaterializedView    ChangeType = "MODIFY_MATERIALIZED_VIEW"
	ChangeTypeAddFunction               ChangeType = "ADD_FUNCTION"
	ChangeTypeDropFunction              ChangeType = "DROP_FUNCTION"
	ChangeTypeModifyFunction            ChangeType = "MODIFY_FUNCTION"
	ChangeTypeAddTrigger                ChangeType = "ADD_TRIGGER"
	ChangeTypeDropTrigger               ChangeType = "DROP_TRIGGER"
	ChangeTypeModifyTrigger             ChangeType = "MODIFY_TRIGGER"
	ChangeTypeAddExtension              ChangeType = "ADD_EXTENSION"
	ChangeTypeDropExtension             ChangeType = "DROP_EXTENSION"
	ChangeTypeModifyExtension           ChangeType = "MODIFY_EXTENSION"
	ChangeTypeAddSequence               ChangeType = "ADD_SEQUENCE"
	ChangeTypeDropSequence              ChangeType = "DROP_SEQUENCE"
	ChangeTypeModifySequence            ChangeType = "MODIFY_SEQUENCE"
	ChangeTypeAddCustomType             ChangeType = "ADD_CUSTOM_TYPE"
	ChangeTypeDropCustomType            ChangeType = "DROP_CUSTOM_TYPE"
	ChangeTypeModifyCustomType          ChangeType = "MODIFY_CUSTOM_TYPE"
	ChangeTypeAddColumn                 ChangeType = "ADD_COLUMN"
	ChangeTypeDropColumn                ChangeType = "DROP_COLUMN"
	ChangeTypeModifyColumnType          ChangeType = "MODIFY_COLUMN_TYPE"
	ChangeTypeModifyColumnNullability   ChangeType = "MODIFY_COLUMN_NULLABILITY"
	ChangeTypeModifyColumnDefault       ChangeType = "MODIFY_COLUMN_DEFAULT"
	ChangeTypeModifyColumnComment       ChangeType = "MODIFY_COLUMN_COMMENT"
	ChangeTypeRenameColumn              ChangeType = "RENAME_COLUMN"
	ChangeTypeAddConstraint             ChangeType = "ADD_CONSTRAINT"
	ChangeTypeDropConstraint            ChangeType = "DROP_CONSTRAINT"
	ChangeTypeModifyConstraint          ChangeType = "MODIFY_CONSTRAINT"
	ChangeTypeAddIndex                  ChangeType = "ADD_INDEX"
	ChangeTypeDropIndex                 ChangeType = "DROP_INDEX"
	ChangeTypeModifyIndex               ChangeType = "MODIFY_INDEX"
	ChangeTypeAddPartition              ChangeType = "ADD_PARTITION"
	ChangeTypeDropPartition             ChangeType = "DROP_PARTITION"
	ChangeTypeAddHypertable             ChangeType = "ADD_HYPERTABLE"
	ChangeTypeDropHypertable            ChangeType = "DROP_HYPERTABLE"
	ChangeTypeModifyHypertable          ChangeType = "MODIFY_HYPERTABLE"
	ChangeTypeAddCompressionPolicy      ChangeType = "ADD_COMPRESSION_POLICY"
	ChangeTypeDropCompressionPolicy     ChangeType = "DROP_COMPRESSION_POLICY"
	ChangeTypeModifyCompressionPolicy   ChangeType = "MODIFY_COMPRESSION_POLICY"
	ChangeTypeAddRetentionPolicy        ChangeType = "ADD_RETENTION_POLICY"
	ChangeTypeDropRetentionPolicy       ChangeType = "DROP_RETENTION_POLICY"
	ChangeTypeModifyRetentionPolicy     ChangeType = "MODIFY_RETENTION_POLICY"
	ChangeTypeAddContinuousAggregate    ChangeType = "ADD_CONTINUOUS_AGGREGATE"
	ChangeTypeDropContinuousAggregate   ChangeType = "DROP_CONTINUOUS_AGGREGATE"
	ChangeTypeModifyContinuousAggregate ChangeType = "MODIFY_CONTINUOUS_AGGREGATE"
)

type ColumnComparator

type ColumnComparator struct {
	// contains filtered or unexported fields
}

func NewColumnComparator

func NewColumnComparator(opts *Options) *ColumnComparator

func (*ColumnComparator) Compare

func (cc *ColumnComparator) Compare(
	result *DiffResult,
	tableKey string,
	currentTable *schema.Table,
	current, desired *schema.Table,
)

type ConstraintComparator

type ConstraintComparator struct {
	// contains filtered or unexported fields
}

func NewConstraintComparator

func NewConstraintComparator(opts *Options) *ConstraintComparator

func (*ConstraintComparator) Compare

func (cc *ConstraintComparator) Compare(result *DiffResult, current, desired *schema.Table)

type CycleGraph

type CycleGraph[T CycleNode] struct {
	GetEdges     func(T) []T
	FormatNode   func(T) string
	HasRemaining func(T) bool
}

type CycleNode

type CycleNode interface {
	comparable
}

type DiffResult

type DiffResult struct {
	Current  *schema.Database
	Desired  *schema.Database
	Changes  []Change
	Warnings []string
	Stats    DiffStats
}

func (*DiffResult) GetChangesBySeverity

func (dr *DiffResult) GetChangesBySeverity(severity ChangeSeverity) []Change

func (*DiffResult) GetChangesByType

func (dr *DiffResult) GetChangesByType(changeType ChangeType) []Change

func (*DiffResult) HasBreakingChanges

func (dr *DiffResult) HasBreakingChanges() bool

func (*DiffResult) HasChanges

func (dr *DiffResult) HasChanges() bool

func (*DiffResult) Summary

func (dr *DiffResult) Summary() string

type DiffStats

type DiffStats struct {
	TablesAdded        int
	TablesDropped      int
	TablesModified     int
	ColumnsAdded       int
	ColumnsDropped     int
	ColumnsModified    int
	IndexesAdded       int
	IndexesDropped     int
	ConstraintsAdded   int
	ConstraintsDropped int
	ViewsAdded         int
	ViewsDropped       int
	ViewsModified      int
	FunctionsAdded     int
	FunctionsDropped   int
	FunctionsModified  int
}

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

func New

func New(opts *Options) *Differ

func (*Differ) Compare

func (d *Differ) Compare(current, desired *schema.Database) (*DiffResult, error)

type FunctionComparator

type FunctionComparator struct {
	// contains filtered or unexported fields
}

func NewFunctionComparator

func NewFunctionComparator(opts *Options) *FunctionComparator

func (*FunctionComparator) Compare

func (fc *FunctionComparator) Compare(result *DiffResult)

type IndexComparator

type IndexComparator struct {
	// contains filtered or unexported fields
}

func NewIndexComparator

func NewIndexComparator(opts *Options) *IndexComparator

func (*IndexComparator) Compare

func (ic *IndexComparator) Compare(result *DiffResult)

type Options

type Options struct {
	IgnoreComments        bool
	IgnoreOwners          bool
	IgnoreTablespaces     bool
	DetectRenames         bool
	IgnoreIndexNames      bool
	IgnoreConstraintNames bool
}

func DefaultOptions

func DefaultOptions() *Options

type TableComparator

type TableComparator struct {
	// contains filtered or unexported fields
}

func NewTableComparator

func NewTableComparator(opts *Options) *TableComparator

func (*TableComparator) Compare

func (tc *TableComparator) Compare(result *DiffResult)

type TriggerComparator

type TriggerComparator struct{}

func NewTriggerComparator

func NewTriggerComparator() *TriggerComparator

func (*TriggerComparator) Compare

func (tc *TriggerComparator) Compare(result *DiffResult)

type ViewComparator

type ViewComparator struct {
	// contains filtered or unexported fields
}

func NewViewComparator

func NewViewComparator(opts *Options) *ViewComparator

func (*ViewComparator) AreEqual

func (vc *ViewComparator) AreEqual(current, desired schema.View) bool

func (*ViewComparator) CreateAddChange

func (vc *ViewComparator) CreateAddChange(key string, view schema.View) Change

func (*ViewComparator) CreateCommentChange

func (vc *ViewComparator) CreateCommentChange(
	key string,
	view schema.View,
	oldComment, newComment string,
) Change

func (*ViewComparator) CreateDropChange

func (vc *ViewComparator) CreateDropChange(key string, view schema.View) Change

func (*ViewComparator) CreateModifyChange

func (vc *ViewComparator) CreateModifyChange(key string, current, desired schema.View) Change

Jump to

Keyboard shortcuts

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