Registry / database / node-mysql-migration

node-mysql-migration

JSON →
library0.2.1jsnpmunverified

Simple MySQL migration utility for Node.js (v0.2.1, last updated 2014). Provides basic migration framework using plain SQL files with flyway-style naming (V1__description.sql). Each migration file supports only a single SQL statement by default; multiple statements require `multipleStatements: true` in connection config. No rollback support, no programmatic API, minimal error handling. Last release over a decade ago, recommended for legacy projects only.

npm install node-mysql-migration
INSTALL
IMPORT
SIG · NODE-MYSQL-MIGRATI
N
node-mysql-migration
databasejavascriptv0.2.1
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
const migration = require('node-mysql-migration');
import migration from 'node-mysql-migration';
CJS only; no ESM support.
migrate
const { migrate } = require('node-mysql-migration');
Named export available via destructuring.

Initialize connection, run migrations from ./migrations folder with multi-statement support enabled.

const mysql = require('mysql'); const migration = require('node-mysql-migration'); const connection = mysql.createConnection({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', multipleStatements: true // enable for multi-query files }); // Run migrations migration.migrate(connection, './migrations'); // To use CLI, run: node my_db_migrations.js migrate // Also supports: clean (drops all tables) and init (creates schema table)
Debug
Known issues
gotchaBy default, each migration file can contain only ONE SQL statement. Multiple statements cause failure.
fix
Set `multipleStatements: true` in mysql.createConnection() or split into separate migration files.
affects: >=0.0.0
gotchaNo rollback functionality; once applied, migrations cannot be reverted via this tool.
fix
Manually reverse migrations or handle externally.
affects: >=0.0.0
deprecatedPackage unmaintained since 2014; no support for modern MySQL versions or features.
fix
Use an actively maintained alternative like `db-migrate` or `knex`.
affects: >=0.0.0
Errors
Common errors & fixes
Error: ER_PARSE_ERROR: You have an error in your SQL syntax... near 'ALTER TABLE' at line X
Multiple SQL statements in one migration file without `multipleStatements` enabled.
fix
Add `multipleStatements: true` to your mysql connection config, or split into separate files.
TypeError: migration.migrate is not a function
Incorrect import (ESM import instead of CommonJS require).
fix
Use `const migration = require('node-mysql-migration');`
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
mysqloptionalpeer dependency for creating database connections
Agent activity
2 hits · last 30 days
node
2
Resources
node-mysql-migration — npm install node-mysql-migration · libregistry