Skip to content

@web-engine-dev/resources


@web-engine-dev/resources / applyMigrations

Function: applyMigrations()

applyMigrations(data, storedVersion, currentVersion, migrations): Record<string, unknown>

Applies sequential migration functions to transform stored data from storedVersion to currentVersion.

Each migration migrations[n] transforms the data from version n to n + 1. Missing migration steps are skipped gracefully (the data passes through unchanged), which allows partial migration chains during development.

Parameters

data

Record<string, unknown>

The mutable data object at storedVersion

storedVersion

number

The version the data was originally saved with

currentVersion

number

The target schema version

migrations

Readonly<Record<number, SchemaMigration>>

Map of sourceVersion -> migration function

Returns

Record<string, unknown>

The migrated data object at currentVersion

Proprietary software. All rights reserved.