type_bridge.migration.breaking¶
breaking
¶
Breaking change analysis for TypeDB schema migrations.
This module provides classification of schema changes to help determine which changes are safe, require warnings, or are breaking changes.
ChangeCategory
¶
Bases: Enum
Classification of schema changes by severity.
ClassifiedChange
dataclass
¶
A schema change with its classification and recommendation.
BreakingChangeAnalyzer
¶
Analyzes schema diffs to classify changes by severity.
Classification rules: - SAFE: Adding new types, widening role player types - WARNING: Adding required attributes to existing types - BREAKING: Removing types, narrowing role player types, removing roles
Example
analyzer = BreakingChangeAnalyzer() diff = old_schema.compare(new_schema) changes = analyzer.analyze(diff)
for change in changes: print(f"[{change.category.value}] {change.description}") print(f" Recommendation: {change.recommendation}")
analyze
¶
Classify all changes in the schema diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff
|
SchemaDiff
|
SchemaDiff from SchemaInfo.compare() |
required |
Returns:
| Type | Description |
|---|---|
list[ClassifiedChange]
|
List of classified changes with recommendations |
Source code in type_bridge/migration/breaking.py
has_breaking_changes
¶
Quick check for any breaking changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff
|
SchemaDiff
|
SchemaDiff from SchemaInfo.compare() |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if any breaking changes exist |
Source code in type_bridge/migration/breaking.py
has_warnings
¶
Quick check for any warning-level changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff
|
SchemaDiff
|
SchemaDiff from SchemaInfo.compare() |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if any warnings exist |
Source code in type_bridge/migration/breaking.py
get_breaking_changes
¶
Get only breaking changes from the diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff
|
SchemaDiff
|
SchemaDiff from SchemaInfo.compare() |
required |
Returns:
| Type | Description |
|---|---|
list[ClassifiedChange]
|
List of breaking changes only |
Source code in type_bridge/migration/breaking.py
summary
¶
Generate a human-readable summary of classified changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff
|
SchemaDiff
|
SchemaDiff from SchemaInfo.compare() |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted summary string |