@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
| Parameter | Type | Description |
|---|---|---|
fromVersion | number | The schema version of the stored data. |
currentVersion | number | The 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);
}