Skip to content

@statesync/persistence


@statesync/persistence / MigrationFn

Type Alias: MigrationFn()<TOld, TNew> ​

ts
type MigrationFn<TOld, TNew> = (oldData) => TNew;

Defined in: persistence/src/types.ts:321

A pure function that transforms persisted data from one schema version to the next.

Migration functions are applied sequentially -- e.g., v1 -> v2 -> v3 -- so each function only needs to handle a single version step.

Type Parameters ​

Type ParameterDescription
TOldThe shape of the data in the source schema version.
TNewThe shape of the data in the target schema version.

Parameters ​

ParameterTypeDescription
oldDataTOldThe data in the source format.

Returns ​

TNew

The transformed data in the target format.

Released under the MIT License.