Docs¶
Class Model¶
High-level view of the main classes and how they collaborate. Method signatures and minor fields are omitted for readability — see source for details.
classDiagram
direction LR
class MigrationOrchestrator {
<<service>>
}
class MigrationRunner {
<<abstract>>
}
class FileMigrationRunner
class AutoMigrationRunner
class MigrationGraphService {
<<service>>
}
class MigrationGenerator {
<<service>>
}
class DiffResolver {
<<service>>
}
class DatabricksStatementGenerator {
<<service>>
}
class State {
<<abstract>>
}
class DatabaseState
class MigrationState
class StateClient {
<<abstract>>
}
class Migration
class FileMigration
class Operation
class Diff {
<<abstract, event>>
}
class MigrationConflictStrategy {
<<abstract>>
}
%% Orchestration
MigrationOrchestrator --> FileMigrationRunner : pre/post phases
MigrationOrchestrator --> AutoMigrationRunner : auto phase
MigrationOrchestrator --> StateClient
%% Runners
MigrationRunner <|-- FileMigrationRunner
MigrationRunner <|-- AutoMigrationRunner
MigrationRunner --> MigrationState : manages
MigrationRunner --> MigrationGraphService : orders via
FileMigrationRunner --> MigrationConflictStrategy
AutoMigrationRunner --> MigrationGenerator
%% Diff pipeline
MigrationGenerator --> DiffResolver
MigrationGenerator --> Migration : produces
DiffResolver --> DatabaseState : compares
DiffResolver --> Diff : produces
Migration ..> DatabricksStatementGenerator : from_diff()
%% Domain
Migration <|-- FileMigration
Migration *-- Operation
Migration --> Migration : depends_on
MigrationState *-- Migration
%% State
State <|-- DatabaseState
State <|-- MigrationState
State ..> StateClient : persists via
Notes:
- Orchestration.
MigrationOrchestratorruns three phases in order: pre-deployment and post-deployment go throughFileMigrationRunner; the middle "auto" phase goes throughAutoMigrationRunner. Configuration is bundled inMigrationOrchestratorConfig(not shown). - Runners.
MigrationRunneris an abstract base.FileMigrationRunnerloads SQL files from disk and applies aMigrationConflictStrategy(RaiseOnConflict/WarnOnConflict/IgnoreConflict) when previously-applied migrations have been modified or removed.AutoMigrationRunnergenerates migrations from a state diff viaMigrationGenerator. - Diff pipeline.
DiffResolvercompares twoDatabaseStates and emits a typedDiffhierarchy (DatabaseAdded/Removed/Changed,SchemaAdded/Removed/Changed,TableAdded/Removed/Changed,ColumnAdded/Removed/Changed,PrimaryKeyChanged).DatabricksStatementGeneratorrenders eachDiffto SQL whenMigration.from_diffis called. - State.
Stateis the persistence base; concrete states areDatabaseState(a collection ofDatabaseobjects fromcloe_metadata) andMigrationState(a list ofMigration/FileMigration). Read/write is delegated to aStateClient(LocalStateClientorAzureStateClient). - Migrations. Each
Migrationowns a list of frozen, hashableOperations and aMigrationStatus(NEW/PENDING/APPLIED/FAILED/UNDEFINED).FileMigrationaddssource_pathanddepends_on_pathsfor file-based migrations.