Registry / database / mysql-patcher

mysql-patcher

JSON →
library0.7.0jsnpmunverified

A database migration tool for MySQL that applies sequential SQL patch files (e.g., patch-0001-0002.sql) to manage schema changes. Current stable version: 0.7.0 (released March 2015). The package has seen no updates in years and relies on the deprecated mysql npm package (not mysql2). Key differentiator: users must supply their own mysql instance, avoiding dependency conflicts. However, the project is effectively abandoned with no releases since 2015, no TypeScript types, and no support for modern MySQL or async/await patterns. Not recommended for new projects.

npm install mysql-patcher
INSTALL
IMPORT
SIG · MYSQL-PATCHER
M
mysql-patcher
databasejavascriptv0.7.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.

default
const patcher = require('mysql-patcher')
import patcher from 'mysql-patcher'
CommonJS only; no ESM or named exports.
patch
patcher.patch(options, callback)
patcher.patch(options).then(...)
Callback-based API; does not return a promise.
Patcher class
const Patcher = require('mysql-patcher').Patcher; const p = new Patcher(options); p.apply(callback);
import { Patcher } from 'mysql-patcher'
Require destructuring works; ESM import fails.

Shows the typical usage of mysql-patcher: requiring mysql and the patcher, setting options, and calling .patch() with a callback.

const path = require('path'); const mysql = require('mysql'); const patcher = require('mysql-patcher'); const options = { user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '', database: process.env.MYSQL_DB || 'test', dir: path.join(__dirname, 'migrations'), patchKey: 'schema-patch-level', patchLevel: 3, filePrefix: 'patch', metaTable: 'metadata', mysql: mysql, }; patcher.patch(options, (err, res) => { if (err) { console.error('Patch failed:', err); process.exit(1); } console.log('Patch succeeded:', res); });
Debug
Known issues
deprecatedmysql npm package is deprecated; use mysql2 instead
fix
Switch to a migration tool that supports mysql2 or use the 'mysql' package at your own risk.
affects: *
breakingRequires the mysql package to be installed separately; not included as a dependency
fix
Run `npm install mysql` in your project.
affects: *
gotchaPatch files must include an explicit update to the patch-level row in metadata table as the last SQL statement
fix
Ensure every forward patch ends with: `UPDATE metadata SET value = '<new-level>' WHERE name = '<patchKey>';`
affects: *
gotchaReverse patching is disabled by default; must set reversePatchAllowed: true
fix
Add `reversePatchAllowed: true` to options if you need to rollback.
affects: *
deprecatedNo updates since 2015; unmaintained
fix
Consider alternatives like db-migrate, node-pg-migrate, or knex migrations.
affects: >=0.7.0
Errors
Common errors & fixes
Cannot find module 'mysql'
The mysql package is not installed or not passed in options correctly.
fix
Run `npm install mysql` and ensure the 'mysql' option in the options object is the require'd mysql module.
ENOENT: no such file or directory, scandir '...'
The 'dir' option points to a non-existent directory.
fix
Make sure the migrations directory exists and the path is correct.
patch direction error: ...
Reverse patching attempted without enabling reversePatchAllowed.
fix
Set `reversePatchAllowed: true` in options.
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
mysqlrequiredrequired as a peer dependency; user must pass mysql instance to patch()
Agent activity
4 hits · last 30 days
node
4
Resources
mysql-patcher — npm install mysql-patcher · libregistry