npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mysql-node-migrator

v1.3.0

Published

A database change management tool for nodejs and mysql

Downloads

64

Readme

mysql-node-migrator

A library to keep track of change scripts for mysql databases in node, based upon this repository.

Uses promise-mysql (which in turn uses mysqljs/mysql).

mysql-node-migrator uses only .createConnection(), which makes other connection options unavailable.

The migrator will create a table in the database, called migration_schema. This will keep track of the migrations that have been executed.

Installation

To install, use npm:

$ npm install mysql-node-migrator

Naming convention

The migrator depends on that the migrations are located in a folder. It will search this folder for migration scripts using the following pattern: V{version}__{name}.sql (regex: /V(\d+)__([\w_]+)\.sql/).

Examples:

V1__init_script.sql
V2__migrate_users.sql

The version number keeps track on in which order the scripts shall be executed. When a migration script has been run, its version and name will be stored in the database, preventing it from being run again.

Connection

The migrator takes the following parameters: connectionOptions and options.

connectionOptions matches mysqljs connection options.

options is an object with the following structure:

const options = {
  folder: 'sqlMigrations', // The relative path to the folder where the sql scripts are located
  loggingFunction: console, // (optional, default console) The logger function to use (e.g. winston)
  logging: true, // (optional, default true) Whether the migrator shall log its progress
}

Import and execute the migrator as follows:

import migrator from 'mysql-node-migrator';

const options = {
  folder: 'sql_migrations',
};

migrator(databaseConfig, options).then(() => {
  // Migrations finished, do something
});

Multiple statements

In order to execute a script with multiple statements, set connectionOptions.multipleStatements = true.