Registry / database / agnostic-migrator

agnostic-migrator

JSON →
library1.0.0jsnpmunverified

A data storage-agnostic migration library (v1.0.0) that provides a simple, flexible migration framework without built-in storage adapters. Users implement StateStorage and Migration interfaces for their specific database or storage system. The library supports up, down, up-to-latest, rollback-last-batch, and rollback-all operations. It is ideal for projects needing a lightweight, custom migration solution, but requires manual implementation of state tracking and migration logic. Released as a single stable version, it ships TypeScript types and is ESM-only.

npm install agnostic-migrator
INSTALL
IMPORT
SIG · AGNOSTIC-MIGRATOR
A
agnostic-migrator
databasejavascriptv1.0.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.

*
import * as migrator from 'agnostic-migrator'
const migrator = require('agnostic-migrator')
ESM-only package; CommonJS require will fail.
migrateUp
import { migrateUp } from 'agnostic-migrator'
const migrateUp = require('agnostic-migrator').migrateUp
ESM-only; named imports work with both ESM and TypeScript.
StateStorage
import type { StateStorage } from 'agnostic-migrator'
import { StateStorage } from 'agnostic-migrator'
StateStorage is a TypeScript interface; use type import to avoid runtime import.

Demonstrates basic usage: implementing custom StateStorage and Migration, then running and rolling back migrations.

import * as migrator from 'agnostic-migrator'; // Implement StateStorage and Migration interfaces import { InMemoryStateStorage, MockMigration } from './my-implementations'; const stateStorage = new InMemoryStateStorage(); const migrations = [ new MockMigration({ identifier: '001', up: () => {}, down: () => {} }), new MockMigration({ identifier: '002', up: () => {}, down: () => {} }), ]; // Run all up migrations migrator.migrateUpToLatest({ migrations, stateStorage }); // Rollback last batch migrator.rollbackLastBatch({ migrations, stateStorage });
Debug
Known issues
breakingPackage is ESM-only. CommonJS require() will not work.
fix
Use 'import' syntax or set 'type': 'module' in package.json.
affects: >=1.0.0
gotchaYou must implement StateStorage and Migration interfaces; no built-in adapters.
fix
Provide your own storage (e.g., database table) and migration logic.
affects: >=1.0.0
gotchaOrder of migrations array is crucial; only sequential identifiers are sorted correctly.
fix
Ensure migrations array is in the order you want to run them.
affects: >=1.0.0
gotchamigrateUp with undefined runs first pending; migrateDown with undefined runs last applied.
fix
Be explicit about identifier to avoid unexpected migrations.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'agnostic-migrator'
Package not installed or ESM module resolution issue.
fix
Run 'npm install agnostic-migrator' and ensure 'type': 'module' or '.js' extension in imports.
require() of ES Module /node_modules/agnostic-migrator/index.js not supported
Using CommonJS require on ESM-only package.
fix
Switch to dynamic import() or set 'type': 'module' and use import statements.
TypeError: migrator.migrateUp is not a function
Incorrect import style (e.g., default import instead of namespace).
fix
Use 'import * as migrator from 'agnostic-migrator'' or named import.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
26
OpenAI (training)
2
Resources
agnostic-migrator — npm install agnostic-migrator · libregistry