mysql-migrator is an npm package for managing MySQL/MariaDB database migrations and data seeding in Node.js projects, currently at version 2.0.0. It provides a simple CLI-like interface to create and run migration and seeding files with built-in rollback support. Key differentiators include support for both ES6 and CommonJS module systems, a straightforward API using a Migrator class, and built-in table creation/drop helpers via the tbl object. The package is actively maintained and integrates directly with npm scripts for ease of use.
npm install mysql-migratorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a migrator instance, creates a migration, runs it up, and rolls back.
Use module.exports = { up: async (tbl) => { ... } } in migration files.Update to new Migrator({ host, user, password, database }, migrationsPath) syntax.Change exports.up to module.exports = { up: ... }Run rollback multiple times to revert multiple batches.
Run 'npm install mysql-migrator' and ensure import statements match the module system.
Use import { Migrator } from 'mysql-migrator' for ESM or const { Migrator } = require('mysql-migrator') for CJS.Ensure up/rollback function signature is async (tbl) => { ... }Check DB_USER, DB_PASSWORD, host, and port in dbConfig.