Registry / database / termigrator

termigrator

JSON →
library1.1.5jsnpmunverified

A low level, database agnostic migration client for Node.js. Version 1.1.5 is current. It makes no assumptions about migration structure or storage, requiring users to define custom handlers for executing migrations, tracking state, and logging. The CLI was extracted to a separate termigrator-cli package as of v1.0.0. Compared to alternatives like db-migrate or knex migrations, Termigrator offers maximum flexibility but requires more manual setup.

npm install termigrator
INSTALL
IMPORT
SIG · TERMIGRATOR
T
termigrator
databasejavascriptv1.1.5
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.

Migrator
import { Migrator } from 'termigrator'
const Migrator = require('termigrator').Migrator
ESM-only; CommonJS require still works but destructure differently.
Cli
import Cli from 'termigrator-cli'
import { Cli } from 'termigrator'
Cli is in a separate package termigrator-cli since v1.0.0.
default export
import Termigrator from 'termigrator'
There is no default export; only named export Migrator.

Creates a Migrator instance with custom handlers and runs pending migrations.

import { Migrator } from 'termigrator'; const migrator = new Migrator({ execMigration: async (id, direction) => { if (direction === 'up') { await db.execute('...'); } else { await db.execute('...'); } }, getLastExecuted: async () => { const row = await db.get('SELECT id FROM migrations ORDER BY id DESC LIMIT 1'); return row?.id; }, getMigrations: async () => { return ['1.0.0', '1.1.0', '2.0.0']; }, log: async (id, direction, event) => { await db.insert('INSERT INTO migration_log VALUES (?, ?, ?)', [id, direction, event]); }, }); await migrator.up(); console.log('Migrations executed');
Debug
Known issues
breakingCLI functionality removed in v1.0.0 and moved to termigrator-cli.
fix
Install termigrator-cli separately and import Cli from there.
affects: >=1.0.0
gotchaAll handler functions must return Promises; async/await recommended.
fix
Ensure each handler returns a Promise.
affects: *
gotchaOptions object must include all four handlers: execMigration, getLastExecuted, getMigrations, log.
fix
Define all four required functions.
affects: *
gotchaMigration ids are compared as strings, not semver. Sorting is not automatic.
fix
Ensure getMigrations returns ids in execution order (e.g., sorted).
affects: *
Errors
Common errors & fixes
TypeError: migrator.up is not a function
Attempting to call up() on a plain object instead of Migrator instance.
fix
Create instance: const migrator = new Migrator({...}); then call migrator.up().
Error: Cannot find module 'termigrator'
Package not installed or require path incorrect.
fix
Run: npm install termigrator
TypeError: options.execMigration is not a function
Missing or non-function execMigration handler in options.
fix
Provide a function for execMigration that returns a Promise.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
Meta
1
Amazon
1
OpenAI (training)
1
Resources