{"id":43318,"library":"mysql-patcher","title":"mysql-patcher","description":"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.","status":"deprecated","version":"0.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/chilts/mysql-patcher","tags":["javascript","mysql"],"install":[{"cmd":"npm install mysql-patcher","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-patcher","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-patcher","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required as a peer dependency; user must pass mysql instance to patch()","package":"mysql","optional":false}],"imports":[{"note":"CommonJS only; no ESM or named exports.","wrong":"import patcher from 'mysql-patcher'","symbol":"default","correct":"const patcher = require('mysql-patcher')"},{"note":"Callback-based API; does not return a promise.","wrong":"patcher.patch(options).then(...)","symbol":"patch","correct":"patcher.patch(options, callback)"},{"note":"Require destructuring works; ESM import fails.","wrong":"import { Patcher } from 'mysql-patcher'","symbol":"Patcher class","correct":"const Patcher = require('mysql-patcher').Patcher;\nconst p = new Patcher(options);\np.apply(callback);"}],"quickstart":{"code":"const path = require('path');\nconst mysql = require('mysql');\nconst patcher = require('mysql-patcher');\n\nconst options = {\n  user: process.env.MYSQL_USER || 'root',\n  password: process.env.MYSQL_PASSWORD || '',\n  database: process.env.MYSQL_DB || 'test',\n  dir: path.join(__dirname, 'migrations'),\n  patchKey: 'schema-patch-level',\n  patchLevel: 3,\n  filePrefix: 'patch',\n  metaTable: 'metadata',\n  mysql: mysql,\n};\n\npatcher.patch(options, (err, res) => {\n  if (err) {\n    console.error('Patch failed:', err);\n    process.exit(1);\n  }\n  console.log('Patch succeeded:', res);\n});","lang":"javascript","description":"Shows the typical usage of mysql-patcher: requiring mysql and the patcher, setting options, and calling .patch() with a callback."},"warnings":[{"fix":"Switch to a migration tool that supports mysql2 or use the 'mysql' package at your own risk.","message":"mysql npm package is deprecated; use mysql2 instead","severity":"deprecated","affected_versions":"*"},{"fix":"Run `npm install mysql` in your project.","message":"Requires the mysql package to be installed separately; not included as a dependency","severity":"breaking","affected_versions":"*"},{"fix":"Ensure every forward patch ends with: `UPDATE metadata SET value = '<new-level>' WHERE name = '<patchKey>';`","message":"Patch files must include an explicit update to the patch-level row in metadata table as the last SQL statement","severity":"gotcha","affected_versions":"*"},{"fix":"Add `reversePatchAllowed: true` to options if you need to rollback.","message":"Reverse patching is disabled by default; must set reversePatchAllowed: true","severity":"gotcha","affected_versions":"*"},{"fix":"Consider alternatives like db-migrate, node-pg-migrate, or knex migrations.","message":"No updates since 2015; unmaintained","severity":"deprecated","affected_versions":">=0.7.0"}],"env_vars":null,"search_vec":"'0.7.0':25 '2015':28,69 'abandon':64 'appli':11 'async/await':80 'avoid':56 'chang':21 'conflict':58 'current':22 'databas':5 'depend':57 'deprec':41 'differenti':48 'e.g':16 'effect':63 'file':15 'howev':59 'instanc':55 'javascript':87 'key':47 'manag':19 'march':27 'migrat':6 'modern':77 'must':50 'mysql':2,9,42,54,78,88 'mysql-patch':1 'mysql2':46 'new':85 'npm':43 'packag':30,44 'patch':14 'patch-0001-0002.sql':17 'patcher':3 'pattern':81 'project':61,86 'recommend':83 'releas':26,67 'reli':38 'schema':20 'seen':32 'sequenti':12 'sinc':68 'sql':13 'stabl':23 'suppli':51 'support':75 'tool':7 'type':72 'typescript':71 'updat':34 'user':49 'version':24 'year':36","created_at":"2026-06-05T16:59:13.536442+00:00","updated_at":"2026-06-05T16:59:13.536442+00:00","problems":[{"fix":"Run `npm install mysql` and ensure the 'mysql' option in the options object is the require'd mysql module.","cause":"The mysql package is not installed or not passed in options correctly.","error":"Cannot find module 'mysql'"},{"fix":"Make sure the migrations directory exists and the path is correct.","cause":"The 'dir' option points to a non-existent directory.","error":"ENOENT: no such file or directory, scandir '...'"},{"fix":"Set `reversePatchAllowed: true` in options.","cause":"Reverse patching attempted without enabling reversePatchAllowed.","error":"patch direction error: ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/chilts/mysql-patcher","github":"https://github.com/chilts/mysql-patcher","docs":null,"changelog":null,"pypi":null,"npm":"mysql-patcher","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}