graflo.migrate¶
Migration planning and execution primitives.
Modules:
| Name | Description |
|---|---|
diff |
Schema diff engine for migration planning. |
drift |
Live schema drift: what a database holds that its declared schema does not. |
emitters |
Backend emitters for migration execution. |
executor |
Migration execution orchestrator. |
io |
I/O utilities for migration workflows. |
models |
Typed migration domain models. |
planner |
Migration plan ordering and policy filters. |
risk |
Risk classification and compatibility helpers. |
store |
Migration history persistence. |
Attributes¶
__all__ = ['LiveSchemaDrift', 'MigrationOperation', 'MigrationPlan', 'MigrationPlanner', 'MigrationRecord', 'OperationType', 'RiskLevel', 'SchemaConflict', 'SchemaDiff', 'SchemaDiffResult', 'compare_live_schema']
module-attribute
¶
Classes¶
LiveSchemaDrift
¶
Bases: BaseModel
Presence-only differences between a live database and its schema.
Names are logical where the declared schema maps them, and the raw storage name where it does not (anything undeclared has no logical name).
Source code in graflo/migrate/drift.py
Attributes¶
has_drift
property
¶
True when the database holds anything the schema does not declare.
missing_edges = Field(default_factory=list, description='Declared (source, relation, target) patterns with no edge.')
class-attribute
instance-attribute
¶
missing_properties = Field(default_factory=dict, description='Per declared vertex type present in the database, declared properties no examined node carries.')
class-attribute
instance-attribute
¶
missing_vertices = Field(default_factory=list, description='Declared vertex types with no node in the database (or sample).')
class-attribute
instance-attribute
¶
sampled = Field(default=True, description="True when introspection examined a sample of rows per type, so a missing entry means 'not seen in the sample', not 'absent'.")
class-attribute
instance-attribute
¶
undeclared_edges = Field(default_factory=list, description='(source, relation, target) patterns in the data, not declared.')
class-attribute
instance-attribute
¶
undeclared_properties = Field(default_factory=dict, description='Per declared vertex type, properties present but not declared.')
class-attribute
instance-attribute
¶
undeclared_vertices = Field(default_factory=list, description='Vertex types in the database that the schema does not declare.')
class-attribute
instance-attribute
¶
MigrationOperation
¶
Bases: BaseModel
A typed migration operation emitted from schema diff.
Source code in graflo/migrate/models.py
Attributes¶
metadata = Field(default_factory=dict, description='Additional operation metadata.')
class-attribute
instance-attribute
¶
new_value = Field(default=None, description='New value, when relevant.')
class-attribute
instance-attribute
¶
old_value = Field(default=None, description='Old value, when relevant.')
class-attribute
instance-attribute
¶
op_type = Field(..., description='Operation type identifier.')
class-attribute
instance-attribute
¶
reversible = Field(default=True, description='Whether operation is reversible without external backup.')
class-attribute
instance-attribute
¶
risk = Field(..., description='Operation risk level.')
class-attribute
instance-attribute
¶
target = Field(..., description='Operation target path.')
class-attribute
instance-attribute
¶
MigrationPlan
¶
Bases: BaseModel
Ordered migration operations ready for preview or execution.
Source code in graflo/migrate/models.py
MigrationPlanner
¶
Translate schema diff result into ordered execution plan.
Source code in graflo/migrate/planner.py
Attributes¶
allow_high_risk = allow_high_risk
instance-attribute
¶
Methods:¶
__init__(allow_high_risk=False)
¶
build(diff_result)
¶
Build ordered plan with risk gate filtering.
Source code in graflo/migrate/planner.py
MigrationRecord
¶
Bases: BaseModel
Applied migration metadata persisted by migration store.
Source code in graflo/migrate/models.py
Attributes¶
applied_at = Field(default_factory=lambda: datetime.now(UTC).isoformat())
class-attribute
instance-attribute
¶
backend
instance-attribute
¶
operations = Field(default_factory=list, description="The operations applied, in order. Records written before full operations were stored hold only each operation's type.")
class-attribute
instance-attribute
¶
reversible = True
class-attribute
instance-attribute
¶
revision
instance-attribute
¶
schema_hash
instance-attribute
¶
OperationType
¶
Bases: StrEnum
Canonical migration operation type identifiers.
Source code in graflo/migrate/models.py
Attributes¶
ADD_EDGE = 'ADD_EDGE'
class-attribute
instance-attribute
¶
ADD_EDGE_FIELD = 'ADD_EDGE_FIELD'
class-attribute
instance-attribute
¶
ADD_EDGE_INDEX = 'ADD_EDGE_INDEX'
class-attribute
instance-attribute
¶
ADD_VERTEX = 'ADD_VERTEX'
class-attribute
instance-attribute
¶
ADD_VERTEX_FIELD = 'ADD_VERTEX_FIELD'
class-attribute
instance-attribute
¶
ADD_VERTEX_INDEX = 'ADD_VERTEX_INDEX'
class-attribute
instance-attribute
¶
CHANGE_EDGE_FIELD_TYPE = 'CHANGE_EDGE_FIELD_TYPE'
class-attribute
instance-attribute
¶
CHANGE_EDGE_IDENTITY = 'CHANGE_EDGE_IDENTITY'
class-attribute
instance-attribute
¶
CHANGE_INDEX = 'CHANGE_INDEX'
class-attribute
instance-attribute
¶
CHANGE_SECONDARY_IDENTITY = 'CHANGE_SECONDARY_IDENTITY'
class-attribute
instance-attribute
¶
CHANGE_VERTEX_FIELD_TYPE = 'CHANGE_VERTEX_FIELD_TYPE'
class-attribute
instance-attribute
¶
CHANGE_VERTEX_IDENTITY = 'CHANGE_VERTEX_IDENTITY'
class-attribute
instance-attribute
¶
REKEY_VERTEX = 'REKEY_VERTEX'
class-attribute
instance-attribute
¶
REMOVE_EDGE = 'REMOVE_EDGE'
class-attribute
instance-attribute
¶
REMOVE_EDGE_FIELD = 'REMOVE_EDGE_FIELD'
class-attribute
instance-attribute
¶
REMOVE_EDGE_INDEX = 'REMOVE_EDGE_INDEX'
class-attribute
instance-attribute
¶
REMOVE_VERTEX = 'REMOVE_VERTEX'
class-attribute
instance-attribute
¶
REMOVE_VERTEX_FIELD = 'REMOVE_VERTEX_FIELD'
class-attribute
instance-attribute
¶
REMOVE_VERTEX_INDEX = 'REMOVE_VERTEX_INDEX'
class-attribute
instance-attribute
¶
RiskLevel
¶
Bases: StrEnum
Risk levels attached to migration operations.
Source code in graflo/migrate/models.py
SchemaConflict
¶
Bases: BaseModel
A conflict discovered during planning or validation.
Source code in graflo/migrate/models.py
SchemaDiff
¶
Compute a typed structural diff between two schemas.
Source code in graflo/migrate/diff.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
Attributes¶
schema_new = schema_new
instance-attribute
¶
schema_old = schema_old
instance-attribute
¶
Methods:¶
__init__(schema_old, schema_new)
¶
compare()
¶
Build a full diff result including operations/conflicts/warnings.
Source code in graflo/migrate/diff.py
conflicts()
¶
Return conflicts from latest compare call.
is_backward_compatible()
¶
operations()
¶
Return diff operations, calculating if needed.
risk_assessment()
¶
Map operation keys to risk labels.
SchemaDiffResult
¶
Bases: BaseModel
Structured schema diff with operations and diagnostics.
Source code in graflo/migrate/models.py
Functions:¶
compare_live_schema(declared, observed, *, db_flavor, sampled=True)
¶
Compare an introspected schema with the declared one, by presence only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
declared
|
Schema
|
The schema the database is supposed to follow. |
required |
observed
|
Schema
|
What |
required |
db_flavor
|
DBType
|
The database's flavor, for mapping logical names to storage names. |
required |
sampled
|
bool
|
Whether introspection sampled rows rather than reading a complete catalogue. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
LiveSchemaDrift |
LiveSchemaDrift
|
every difference, with lists sorted for stable output. |
Source code in graflo/migrate/drift.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |