Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateDumpHeader ¶
GenerateDumpHeader generates the header for database dumps with metadata
Types ¶
type ColumnDiff ¶
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 ¶
GenerateMigration compares two IR schemas and returns the SQL differences GenerateMigration generates the migration diff using standard "smart qualification" (the target-schema prefix is omitted on entity names).
func GenerateMigrationWithOptions ¶ added in v1.12.0
func GenerateMigrationWithOptions(oldIR, newIR *ir.IR, targetSchema string, qualifySchema bool) []Diff
GenerateMigrationWithOptions is like GenerateMigration, but when qualifySchema is true the empty-to-target create DDL used by `dump --qualify-schema` forces schema qualification for structural object identifiers where the IR carries schema identity (table/view/index/sequence/type/function/procedure/policy names and ON/REFERENCES/OWNED BY/COMMENT targets). This option is intended for dump's empty-to-target CREATE/ADD output; other diff paths are not part of the contract and may still use standard smart qualification. Same-schema type references stay bare because the IR stores them without schema identity (#493). Default behavior (false) is unchanged for plan/apply.
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 DiffTypeTablePersistence DiffTypeView DiffTypeViewTrigger DiffTypeViewComment DiffTypeMaterializedView DiffTypeMaterializedViewComment DiffTypeMaterializedViewIndex DiffTypeMaterializedViewIndexComment DiffTypeFunction DiffTypeProcedure DiffTypeAggregate DiffTypeSequence DiffTypeType DiffTypeDomain DiffTypeComment DiffTypeDefaultPrivilege DiffTypePrivilege DiffTypeRevokedDefaultPrivilege DiffTypeColumnPrivilege )
func (DiffType) MarshalJSON ¶
MarshalJSON marshals DiffType to JSON as a string
func (*DiffType) UnmarshalJSON ¶
UnmarshalJSON unmarshals DiffType from JSON 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