Registry / database / mysql-migration

mysql-migration

JSON →
library1.4.0jsnpmunverified

A CLI tool for managing versioned MySQL schema migrations with TypeScript support, transaction-based rollbacks, and dry-run previews. Current stable version is 1.4.0, released under a custom license and requiring Node.js >=18. It supports multiple databases, timestamped migration files, forward/backward batch execution, and CI/CD integration. Key differentiators include automatic transactional rollback on failure, built-in dry-run mode, CommonJS/ESM conversion utilities, and full TypeScript type definitions. The tool uses a JSON configuration file and relies on mysql2 for database connections.

npm install mysql-migration
INSTALL
IMPORT
SIG · MYSQL-MIGRATION
M
mysql-migration
databasejavascriptv1.4.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.

init
npx mysql-migration init
npm run mysql-migration init
CLI tool used via npx or local install; no JavaScript import.
create
npx mysql-migration create <name> <dbName>
npx mysql-migration create <dbName> <name>
Arguments are (name, dbName) in that order.
run
npx mysql-migration run <dbName> [--transaction]
npx mysql-migration run --transaction <dbName>
Options like --transaction come after the dbName argument.

Initialize project, create a migration, preview it with dry-run, then apply it with transaction support.

npx mysql-migration init npx mysql-migration create add_users_table main-db npx mysql-migration run main-db --dry-run npx mysql-migration run main-db --transaction
Debug
Known issues
breakingNode.js version requirement: >=18.0.0
fix
Upgrade Node.js to 18 or later.
affects: >=1.4.0
gotchaConfiguration file must be named mysql-migration.config.json and placed in the migrations/ directory (or custom path).
fix
Ensure config file is at <project>/migrations/mysql-migration.config.json or specify custom path.
affects: >=1.0.0
gotchaDry-run mode does not validate SQL syntax; it only previews migration order and content.
fix
Use --transaction for actual validation via rollback on failure.
affects: >=1.0.0
gotchaMigration files are CommonJS (.js) by default. Use to-esm or to-cjs commands to convert between module systems.
fix
Run npx mysql-migration to-esm <dbName> to convert to ESM.
affects: >=1.0.0
deprecatedOlder versions may not support the rollback command with batch number.
fix
Upgrade to >=1.3.0 for batch rollback support.
affects: <1.3.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
mysql2 is not installed, but it's an optional peer dependency.
fix
Install mysql2: npm install mysql2
Error: getaddrinfo ENOTFOUND db_host
Database host is unreachable or misconfigured in mysql-migration.config.json.
fix
Verify host, port, and network connectivity in config.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host'
Incorrect database credentials in configuration.
fix
Check user, password, and host in mysql-migration.config.json.
Error: ER_BAD_DB_ERROR: Unknown database 'db_name'
The specified database does not exist on the MySQL server.
fix
Create the database: CREATE DATABASE db_name;
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
mysql2optionalRequired for MySQL database connectivity and query execution.
Agent activity
15 hits · last 30 days
node
12
Amazon
1
Resources
mysql-migration — npm install mysql-migration · libregistry