Registry / database / mysql2-migration

mysql2-migration

JSON →
library2.2.1jsnpmunverified

A migration tool for MySQL using the mysql2 package in Node.js, version 2.2.1. It provides a simple CLI to create and run database migrations, similar to other migration frameworks. The package requires a config file at ./config/database.js and is executed via a single migration.js file. Supports up, down, and refresh commands, with options to run specific migrations or limit the number. It targets Node.js >= 12.22.12 and is available on npm as mysql2-migration.

npm install mysql2-migration
INSTALL
IMPORT
SIG · MYSQL2-MIGRATION
M
mysql2-migration
databasejavascriptv2.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.

mysql2-migration (module)
require('mysql2-migrations')
import 'mysql2-migrations'
ESM not supported; must use CommonJS require().

Shows minimal setup: create a config, run a migration script.

// migration.js require('mysql2-migrations') // Then run: node migration.js create my_migration // node migration.js up // node migration.js down
Debug
Known issues
gotchaPackage name is 'mysql2-migration', but the require path is 'mysql2-migrations' with an 's'.
fix
Use require('mysql2-migrations')
affects: *
gotchaConfig file must be at ./config/database.js relative to the project root.
fix
Place config in ./config/database.js or adjust CWD.
affects: *
gotchaCLI commands are run via 'node migration.js', not as a global command.
fix
Run from project root as: node migration.js <command>
affects: *
Errors
Common errors & fixes
Cannot find module 'mysql2-migrations'
Package name has 's' but npm package is 'mysql2-migration'.
fix
Install npm i mysql2-migration and use require('mysql2-migrations')
No database config found
Config file ./config/database.js missing or not proper.
fix
Create ./config/database.js with required fields.
Column type 'tnteger' is not supported
Typo in migration create command: 'tnteger' instead of 'integer'.
fix
Use correct type: string, integer, etc.
Upgrade
Version history
2.2.1latest on npm
Audit
Dependencies
mysql2requiredRequired for database connection; peer dependency
Agent activity
10 hits · last 30 days
node
8
Resources
mysql2-migration — npm install mysql2-migration · libregistry