Registry / storage / redux-storage-decorator-migrate

redux-storage-decorator-migrate

JSON →
library1.1.0jsnpmunverified

A decorator for redux-storage that adds versioned state migration capabilities. Version 1.1.0 is the latest stable release (last updated 2016). It allows defining migration functions keyed by version number, automatically applied when the stored version differs from the current version. Unlike manual migration checks, this integrates directly with redux-storage's engine pipeline. The package is simple but has no active development and relies on the now-deprecated redux-storage package.

npm install redux-storage-decorator-migrate
INSTALL
IMPORT
SIG · REDUX-STORAGE-DECO
R
redux-storage-decorator-migrate
storagejavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
✓ import migrate from 'redux-storage-decorator-migrate'
✗ const { migrate } = require('redux-storage-decorator-migrate')
The default export is a function that wraps an engine. Named exports also exist.
buildMigrationEngine
✓ import { buildMigrationEngine } from 'redux-storage-decorator-migrate'
✗ import buildMigrationEngine from 'redux-storage-decorator-migrate'
buildMigrationEngine is a named export, not default.
migrate function
✓ const engine = migrate(engine, currentVersion);
✗ const engine = new migrate(engine);
migrate is a function, not a constructor. It returns a decorator engine.

Shows how to create a versioned storage engine with migrations and how to test migrations without a store using buildMigrationEngine.

import migrate, { buildMigrationEngine } from 'redux-storage-decorator-migrate'; import createEngine from 'redux-storage-engine-localstorage'; const engine = createEngine('my-app'); const version = 3; const decoratedEngine = migrate(engine, version); decoratedEngine.addMigration(1, (state) => { // e.g., state.user.name -> state.user.displayName return { ...state, user: { displayName: state.user.name } }; }); decoratedEngine.addMigration(2, (state) => { return { ...state, newFeature: 'initial value' }; }); decoratedEngine.addMigration(3, (state) => { return state; // noop }); // Or test a migration in isolation: const testState = { 'redux-storage-decorators-migrate-version': 0, data: 'old' }; const migration = { version: 1, migration: (s) => ({ ...s, data: 'new' }) }; const migrationEngine = buildMigrationEngine(1, 'version-key', [migration]); const result = migrationEngine(testState); console.log(result.data); // 'new'
Debug
Known issues
deprecatedThis package is designed for redux-storage, which is deprecated in favor of redux-persist.
fix
Migrate to redux-persist with its own migration support or use a different state management approach.
affects: >=1.0.0
gotchaThe default version key used internally is 'redux-storage-decorators-migrate-version'. Changing it requires using buildMigrationEngine.
fix
Use buildMigrationEngine(version, versionKey, migrations) to specify a custom key.
affects: >=1.0.0
gotchaMigrations must be added via addMigration after calling migrate(). Adding them before will have no effect.
fix
Ensure you call migrate() first, then addMigration() in the correct order.
affects: >=1.0.0
deprecatedPackage is not actively maintained; last update in 2016. May have unaddressed vulnerabilities.
fix
Consider using a more modern alternative like redux-persist with migrations.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'redux-storage'
The peer dependency redux-storage is not installed.
fix
npm install redux-storage
TypeError: migrate is not a function
Using a named import where default import is required, or vice versa.
fix
Use default import: import migrate from 'redux-storage-decorator-migrate'
Uncaught TypeError: engine.addMigration is not a function
Forgetting to call migrate() on the engine before adding migrations.
fix
First decorate: const decorated = migrate(engine, version); then call decorated.addMigration(...).
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
Amazon
1
Resources
redux-storage-decorator-migrate — npm install redux-storage-decorator-migrate · libregistry