Registry / database / db-migrate-mysql

db-migrate-mysql

JSON →
library3.0.0jsnpmunverified

MySQL database driver for the db-migrate migration framework. Version 3.0.0 supports MySQL connections and schema changes. Released under MIT license. This driver allows db-migrate to manage MySQL database migrations, compatible with mysql and mysql2 clients. Differentiating from direct MySQL client usage, it integrates with db-migrate's migration management system, providing up/down migrations, seeding, and CLI support.

npm install db-migrate-mysql
INSTALL
IMPORT
SIG · DB-MIGRATE-MYSQL
D
db-migrate-mysql
databasejavascriptv3.0.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 MySQLDriver = require('db-migrate-mysql');
import MySQLDriver from 'db-migrate-mysql';
Package is CommonJS; no default ESM export. Use require() and access via .MySQLDriver if needed.
MySQLDriver
const MySQLDriver = require('db-migrate-mysql').MySQLDriver;
const { MySQLDriver } = require('db-migrate-mysql');
Export structure is nested; MySQLDriver is not a direct export but available as property of the module.
connect
const { connect } = require('db-migrate-mysql');
const connect = require('db-migrate-mysql').connect;
connect is a named export; destructure correctly.

Initialize db-migrate with MySQL driver and run all pending migrations.

const dbmigrate = require('db-migrate'); const instance = dbmigrate.getInstance(true, { config: { driver: 'mysql', options: { host: process.env.MYSQL_HOST || 'localhost', port: process.env.MYSQL_PORT || 3306, user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '', database: process.env.MYSQL_DATABASE || 'test' } } }); instance.up();
Debug
Known issues
breakingVersion 3.0.0 drops support for mysql driver; use 'mysql2' instead. Set 'options.driver: "mysql2"'.
fix
Update configuration to use mysql2 driver: 'driver: "mysql2"' and install mysql2 package.
affects: >=3.0.0
deprecatedUsing `.then()` and `.catch()` on migration promises is deprecated; use async/await.
fix
Refactor to async/await: `await instance.up();`
affects: >=2.0.0
gotchaThe driver expects a host option; missing host may cause connection errors.
fix
Always include `host: process.env.MYSQL_HOST || 'localhost'` in config.
affects: all
gotchaDatabase migrations may fail if the user lacks CREATE or ALTER privileges.
fix
Grant necessary privileges: `GRANT ALL ON db.* TO 'user'@'host';`
affects: all
breakingVersion 2.0.0 changed to use bluebird promises instead of native promises.
fix
Ensure your code uses bluebird-compatible chaining if mixing .then() with other libraries.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'db-migrate-mysql'
Package not installed in node_modules.
fix
npm install db-migrate-mysql
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
Invalid credentials in database configuration.
fix
Check MYSQL_USER and MYSQL_PASSWORD environment variables or config options.
TypeError: instance.up is not a function
db-migrate instance not properly initialized; missing driver config.
fix
Ensure getInstance() called with valid config including driver: 'mysql'.
Error: ER_BAD_DB_ERROR: Unknown database 'test'
Database specified in config does not exist.
fix
Create the database first: `CREATE DATABASE test;`
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
db-migrate-baserequiredCore migration logic and base driver class
bluebirdrequiredPromise implementation for async operations
lodashrequiredUtility functions for object manipulation
Agent activity
9 hits · last 30 days
node
8
Resources
db-migrate-mysql — npm install db-migrate-mysql · libregistry