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

migres

v2.0.1

Published

Dead simple database migrations for PostgreSQL

Readme

migres

Dead simple database migrations for PostgreSQL

NPM

Motivation

I've never been a huge fan of ORM-y solutions for database migrations - I like extremely simple setups, requiring little to no configuration, that use pure SQL. This package essentially just automates what I had been doing by hand up til now, whilst adding some safeguards to prevent multiple redundant queries and errors of that nature.

Setup

migres assumes that you already have postgres running, and that you already have a database instance to connect and migrate to.

In order to connect to the database instance itself, migres expects (in node-postgres fashion) that you set the following environment variables:

  • PGDATABASE
  • PGHOST
  • PGPASSWORD
  • PGPORT
  • PGUSER

migres has support for .env files out of the box by leveraging dotenv. By default migres looks for a file named .env in the current directory when running, but this can be overriden as shown below.

Usage

migres create   [-m path/to/migrations]
migres commit   [-m path/to/migrations] [-e path/to/.env] [-a]
migres rollback [-m path/to/migrations] [-e path/to/.env] [-a]

Flags

| Flag | Alias | Default | Description | | ------------- | ------------- | ------------- | ------------- | | -m | --migrations | "./postgres_migrations" | (Optional) Path to the folder contaning all of the migration directories. | | -e | --env | "./.env" | (Optional) Path to a .env file to be consumed by dotenv. | | -a | --all | false | (Optional) Commit / rollback to the furthest migration ahead / behind the current cursor, fast-forwarding past the selection menu. |

If you have a .env file and a directory named postgres_migratons in your project root, all you have to do to get started is run:

migres create

And edit the commit.sql and rollback.sql files to reflect your schema changes. Create as few or as many migrations you want and, when you're done, run:

migres commit --all

And that's it!

Notes

The cli won't let you accidently commit a migration you're already past, and it won't let you rollback a migration you're already behind - migres extracts the subset of migrations you can safely run without throwing any errors.

The script creates a _migrations table which keeps a cursor to the current point in the migration your database is at. There's nothing fancy like integrity checking with hashes, so it's more than possible to update your migrations on-the-fly. This might not be desirable for many. I intend on adding optional support for this in the future.