@statesync/persistence / createSimpleMigration
Function: createSimpleMigration()
ts
function createSimpleMigration<T>(config): MigrationHandler<T>;Defined in: persistence/src/migration.ts:230
Creates a MigrationHandler directly from a plain configuration object, without using the builder pattern.
This is a convenience function for simple cases where the builder's fluent API is unnecessary.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The shape of the application state in the current schema version. |
Parameters
| Parameter | Type | Description |
|---|---|---|
config | Omit<MigrationHandler<T>, "validate"> & object | The migration configuration including currentVersion, migrations record, and an optional validate type-guard. |
Returns
A migration handler ready to be used with loadPersistedSnapshot or migrateData.
Example
typescript
const migration = createSimpleMigration<AppState>({
currentVersion: 2,
migrations: {
1: (old) => ({ ...old, newField: 'default' }),
},
});