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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-migration-tool

v0.2.1

Published

NIL: Node mIgration Tool

Readme

NIL: Node mIgration tooL

A simple tool to run sql migration using plain text file

Usage

There is two fashion:

  • as CLI tool; which require $ npm install -g nil
  • as straight module; which require $ npm install nil
$ nil init -c <my-connection-string> # create schema migration table and migration folder
$ nil create 2014-01-01-add-seven-life-cat-etching -c <my-connection-string># create two new migration script (`UP` and `DOWN`)
$ nil up -c <my-connection-string># run all `UP` migration from current to last existing one
$ nil up 2014-01-01-add-seven-life-cat-etching -c <my-connection-string># run all migration `UP` to the specified one
$ nil down -c <my-connection-string># run all migration `DOWN` migration to first one
$ nil down 2014-01-01-add-seven-life-cat-etching -c <my-connection-string># run all migration `DOWN` migration to the specifed one

or

var nil = require("nil");
nil.init("my connection string");

nil.create("my-fancy-migration");

nil.up("my connection string");
nil.up("my connection string", "1111111111111-specific-migration");

nil.down("my connection string");
nil.down("my connection string", "1111111111111-specific-migration");

How it works

Migration as simple SQL scripts. They are all stored in the migration folder. When you create a new migration script it will create two files in the migration folder. One for going up and one for going down. They will have the same name but with a suffix to distinguish them, like this

$ tree migration
migration/
├── 1416635703604-add-seven-life-cat-etching-down.sql
└── 1416635703604-add-seven-life-cat-etching-up.sql

When running a script, NIL will record the name of the script that are already applied to the database. This way the migration scripts can only be applied once. When running a down script, the name of the script is removed from the database.

Grunt module

There is also a grunt plugin for NIL. It's included in this repository. At the moment, Nil is not provided as a separate npm module, all is included in this module. So the loading of the nil grunt task, is a little bit weird, it use a local module.

grunt.initConfig({
  "nil":{
    "options":{
      "connectionString":"postgres://postgres:postgres@localhost/pyramide",
      "migrationFolder":"migration"
    }
  }
});

grunt.loadTasks("./node_modules/nil/tasks");

Be aware of

When reading the file, NIL expect to find normally formatted sql script. Meaning with semi-colon to the end of each command. The command can be spanned on multiple line, it won't affect the execution of the migration.

Missing parts

At the moment it's a simple js file.

  • when using CLI interface, i'd like to be able to save connection string, in a file or environnement in order to reuse it without typing it
  • I want to make plugins out of this. the main will have the logic from executing files, the plugin will have the logic to create connection with given db.

Thanks

Thanks to @fxg42 for the base idea and organization