Registry / database / migration-collection

migration-collection

JSON →
library1.3.20jsnpmunverified

A lightweight, extensible Node.js migration tool supporting filesystem, MSSQL, MariaDB, and PostgreSQL. Version 1.3.20 provides a modular pipeline (feeder, sorter, importer, parser, ledger, end) with customizable components. Steady release cadence; focuses on simplicity and easy extension compared to heavier frameworks like Knex or Umzug.

npm install migration-collection
INSTALL
IMPORT
SIG · MIGRATION-COLLECTI
M
migration-collection
databasejavascriptv1.3.20
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.

MigrationCollection
const { MigrationCollection } = require('migration-collection')
import { MigrationCollection } from 'migration-collection'
Package uses CommonJS; ESM import not supported.
FsFeeder
const { FsFeeder } = require('migration-collection')
const FsFeeder = require('migration-collection').FsFeeder
Also CommonJS named export.
DefaultLedger
const { DefaultLedger } = require('migration-collection')
Named export for basic ledger implementation.

This example shows a complete migration setup with filesystem feeder, integer sorter, SQL importer/parser, and custom ledger functions.

const { MigrationCollection, FsFeeder, IntSorter, SqlImporter, SqlParser, DefaultLedger } = require('migration-collection'); async function runMigrations() { const collection = new MigrationCollection({ feeder: new FsFeeder({ directory: './migrations', extension: '.sql' }), sorter: new IntSorter(), importer: new SqlImporter(), parser: new SqlParser(), ledger: new DefaultLedger({ migrate: async (file) => { /* custom migration logic */ }, isMigrated: async (name) => { /* check if already applied */ }, save: async (name) => { /* record migration */ }, delete: async (name) => { /* remove record */ } }) }); const results = await collection.run(); console.log(results); } runMigrations().catch(console.error);
Debug
Known issues
gotchaLedger methods (migrate, isMigrated, save, delete) must all be provided; they are not optional.
fix
Implement all four methods in the ledger object.
affects: >=1.0.0
deprecatedThe 'migrated' field in migration result objects is boolean but may be renamed in future versions.
fix
Check both 'migrated' and any future field name after upgrading.
affects: >=1.0.0
gotchaFiles are sorted by integer key extracted from filename (e.g., 121_abc.sql -> key 121). Non-numeric prefixes will be ignored.
fix
Ensure all migration filenames start with a numeric prefix followed by an underscore.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mssql'
Optional peer dependency not installed when using SQL Server.
fix
npm install mssql
Error: Ledger.migrate is not a function
Ledger object missing required method.
fix
Provide all ledger methods: migrate, isMigrated, save, delete.
TypeError: feeder.read is not a function
Custom feeder does not implement the required API.
fix
Implement read() method returning an array of file objects.
Upgrade
Version history
1.3.20latest on npm
Audit
Dependencies
mssqloptionalMicrosoft SQL Server support
mysql2optionalMariaDB/MySQL support
pgoptionalPostgreSQL support
Agent activity
12 hits · last 30 days
node
12
Resources
migration-collection — npm install migration-collection · libregistry