config.migration
migration
Configuration migration engine for keecas.
Handles automatic migration of configuration files between schema versions, preserving user values while transforming structure and deprecating/removing keys.
Classes
| Name | Description |
|---|---|
| ConfigMigration | Configuration migration engine. |
ConfigMigration
ConfigMigration()Configuration migration engine.
Methods
| Name | Description |
|---|---|
| needs_migration | Check if config needs migration. |
| get_migration_path | Get ordered list of schema versions to migrate through. |
| migrate | Migrate config through all intermediate versions. |
needs_migration
needs_migration(config_version, current_version)Check if config needs migration.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| config_version | str |
Version of the config file | required |
| current_version | str |
Current schema version | required |
Returns
| Name | Type | Description |
|---|---|---|
bool |
True if migration is needed, False otherwise |
get_migration_path
get_migration_path(from_version, to_version)Get ordered list of schema versions to migrate through.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| from_version | str |
Starting schema version | required |
| to_version | str |
Target schema version | required |
Returns
| Name | Type | Description |
|---|---|---|
list[str] |
List of intermediate versions to migrate through |
migrate
migrate(config_data, from_version, to_version)Migrate config through all intermediate versions.
Preserves all user-customized values while transforming structure and handling deprecated/removed keys according to migration functions.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| config_data | dict |
Configuration dictionary to migrate | required |
| from_version | str |
Starting schema version | required |
| to_version | str |
Target schema version | required |
Returns
| Name | Type | Description |
|---|---|---|
dict |
Migrated configuration dictionary |