Config Migration
interface ConfigMigration
Defines a single-step configuration migration from one version to the next.
Implementations transform a raw YAML map in-place (or return a new map) to upgrade the configuration schema from fromVersion to toVersion. Migrations are registered with MigrationRunner and executed in chain order during YamlConfigManager.load.
Each migration should handle exactly one version increment (e.g., v1 to v2). The MigrationRunner chains multiple migrations together automatically.
Example -- renaming a property from v1 to v2:
object MigrateV1ToV2 : ConfigMigration {
override val fromVersion = 1
override val toVersion = 2
override fun migrate(map: MutableMap<String, Any?>): MutableMap<String, Any?> {
// Rename "serverPort" to "port"
map["port"] = map.remove("serverPort")
// Add a new field with a default
map.putIfAbsent("maxConnections", 100)
return map
}
}
// Register the migration
YamlConfigManager.registerMigration(MyConfig::class, MigrateV1ToV2)Content copied to clipboard
Since
1.0
See also
Functions
Link copied to clipboard
Transforms the raw configuration map from fromVersion to toVersion.