Skip to content

@statesync/persistence


@statesync/persistence / needsMigration

Function: needsMigration()

ts
function needsMigration(fromVersion, currentVersion): boolean;

Defined in: persistence/src/migration.ts:254

Checks whether persisted data requires migration.

Returns true if the stored schema version is older than the current version.

Parameters

ParameterTypeDescription
fromVersionnumberThe schema version of the stored data.
currentVersionnumberThe schema version the application currently expects.

Returns

boolean

true if fromVersion < currentVersion, indicating migration is needed.

Example

typescript
if (needsMigration(storedVersion, 3)) {
  const result = migrateData(data, storedVersion, migrationHandler);
}

Released under the MIT License.