Function: runMigrations()
runMigrations(
data,fromVersion,toVersion,options):MigrationResult
Defined in: packages/core/src/saves/migrations/runner.ts:32
Runs the migration chain to migrate save data from one version to another.
This function:
- Finds the shortest migration path using BFS
- Applies each migration in sequence
- Returns the migrated data or error information
Parameters
data
GameSaveState
The save data to migrate
fromVersion
string
The version the save was created with
toVersion
string
The target version to migrate to (usually current game version)
options
MigrationOptions = {}
Migration behavior options
Returns
Migration result with success status and migrated data
Example
const result = runMigrations(oldSaveData, "1.0.0", "2.0.0");
if (result.success) {
console.log("Migrated data:", result.data);
} else {
console.error("Migration failed:", result.error);
}