differ Package
Thediffer package compares two schemas and detects all differences, classifying each change by type and severity.
Differ
Main type for schema comparison.Options
Compare
Compare two schemas and return detected changes:Example Usage
DiffResult
Contains the comparison results:Change
Represents a single detected difference:ChangeType
Over 40 change types are defined:ChangeSeverity
| Severity | Changes |
|---|---|
| SAFE | Add table, add column (nullable), add index, add function |
| POTENTIALLY_BREAKING | Drop index, modify default, modify view |
| BREAKING | Drop table, drop column, drop extension |
| DATA_MIGRATION_REQUIRED | Incompatible type change, add NOT NULL |
Comparators
Internal comparator types for specific object types:TableComparator
ColumnComparator
ConstraintComparator
IndexComparator
Type Compatibility
The differ includes type compatibility checking:smallint→integer→bigintVARCHAR(n)→VARCHAR(m)wherem > nNUMERIC(p,s)→NUMERIC(p',s')wherep' >= pands' >= s
- Any narrowing (larger to smaller)
- Cross-type changes (integer to text)
Dependency Resolution
Changes are ordered using topological sort:- Extensions before types
- Types before tables
- Tables before constraints
- Tables before indexes
- Tables before views
- Functions before triggers
- Drops in reverse order
See Also
- Schema Diffing - Concept documentation
- Dependency Resolution - Ordering algorithm
- generator Package - DDL generation