A plugin for Mutent (v6) that provides data versioning and migration strategies for entities managed by Mutent stores. Version 1.0.1 is current, stable. It allows defining migration functions per version, automatically applies them when fetching entities with older versions, and supports explicit version control. Released under MIT, maintained by the Mutent ecosystem author. Key differentiator: integrates seamlessly with Mutent's entity lifecycle, offering automatic upgrade/downgrade, error codes for invalid versions or missing strategies, and optional force update. Alternative to manual migration in data stores.
npm install mutent-migrationNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Mutent store with array adapter and migration plugin to automatically upgrade entities from version 0 to 1 by renaming a field.
Use options.explicitVersion or options.forceUpdate if you need migration on create operations.
After migration, you must explicitly call store.update() or adapter method to persist changes if needed.
Ensure migration functions set the version property to the strategy's key (target version).
Define all migration strategies for intermediate versions, not just the final target version.
If you change the key, all entities must use that key; otherwise EMUT_INVALID_ENTITY_VERSION error occurs.
Ensure the version field exists and is a valid number. For missing version, it is treated as 0.
Check entity version and migration options.version. You may need to set version to a higher number or handle future entities.
Add strategies for all versions from entity current version+1 up to options.version.
In the migration function, set the version field to the target version number (e.g., { v: 1, ... }).