diff

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDumpHeader

func GenerateDumpHeader(schemaIR *ir.IR) string

GenerateDumpHeader generates the header for database dumps with metadata

Types

type ColumnDiff

type ColumnDiff struct {
	Old *ir.Column
	New *ir.Column
}

ColumnDiff represents changes to a column

func (*ColumnDiff) GetObjectName

func (d *ColumnDiff) GetObjectName() string

type ConstraintDiff

type ConstraintDiff struct {
	Old *ir.Constraint
	New *ir.Constraint
}

ConstraintDiff represents changes to a constraint

func (*ConstraintDiff) GetObjectName

func (d *ConstraintDiff) GetObjectName() string

type Diff

type Diff struct {
	Statements []SQLStatement `json:"statements"`
	Type       DiffType       `json:"type"`
	Operation  DiffOperation  `json:"operation"` // create, alter, drop, replace
	Path       string         `json:"path"`
	Source     DiffSource     `json:"-"` // interface; not JSON-serializable (see #305)
}

Diff represents one or more related SQL statements with their source change

func GenerateMigration

func GenerateMigration(oldIR, newIR *ir.IR, targetSchema string) []Diff

GenerateMigration compares two IR schemas and returns the SQL differences

type DiffOperation

type DiffOperation int

DiffOperation represents the operation being performed

const (
	DiffOperationCreate DiffOperation = iota
	DiffOperationAlter
	DiffOperationDrop
	// DiffOperationRecreate indicates a DROP that is part of a DROP+CREATE cycle
	// for dependency handling. The object will be recreated, so this should be
	// counted as a modification in summaries, not a destruction.
	DiffOperationRecreate
)

func (DiffOperation) MarshalJSON

func (d DiffOperation) MarshalJSON() ([]byte, error)

MarshalJSON marshals DiffOperation to JSON as a string

func (DiffOperation) String

func (d DiffOperation) String() string

String returns the string representation of DiffOperation

func (*DiffOperation) UnmarshalJSON

func (d *DiffOperation) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals DiffOperation from JSON string

type DiffSource

type DiffSource interface {
	GetObjectName() string // Returns the object name (preserves names with dots like "public.idx_users")
}

DiffSource represents all possible source types for a diff

type DiffType

type DiffType int

DiffType represents the type of database object being changed

const (
	DiffTypeTable DiffType = iota
	DiffTypeTableColumn
	DiffTypeTableIndex
	DiffTypeTableTrigger
	DiffTypeTablePolicy
	DiffTypeTableRLS
	DiffTypeTableConstraint
	DiffTypeTableComment
	DiffTypeTableColumnComment
	DiffTypeTableIndexComment
	DiffTypeView
	DiffTypeViewTrigger
	DiffTypeViewComment
	DiffTypeMaterializedView
	DiffTypeMaterializedViewComment
	DiffTypeMaterializedViewIndex
	DiffTypeMaterializedViewIndexComment
	DiffTypeFunction
	DiffTypeProcedure
	DiffTypeSequence
	DiffTypeType
	DiffTypeDomain
	DiffTypeComment
	DiffTypeDefaultPrivilege
	DiffTypePrivilege
	DiffTypeRevokedDefaultPrivilege
	DiffTypeColumnPrivilege
)

func (DiffType) MarshalJSON

func (d DiffType) MarshalJSON() ([]byte, error)

MarshalJSON marshals DiffType to JSON as a string

func (DiffType) String

func (d DiffType) String() string

String returns the string representation of DiffType

func (*DiffType) UnmarshalJSON

func (d *DiffType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals DiffType from JSON string

type IndexDiff

type IndexDiff struct {
	Old *ir.Index
	New *ir.Index
}

IndexDiff represents changes to an index

func (*IndexDiff) GetObjectName

func (d *IndexDiff) GetObjectName() string

type SQLStatement

type SQLStatement struct {
	SQL                 string `json:"sql,omitempty"`
	CanRunInTransaction bool   `json:"can_run_in_transaction"`
}

SQLStatement represents a single SQL statement with its transaction capability

Jump to

Keyboard shortcuts

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