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

@randy5235/pg-migrations

v0.2.6

Published

Tool to run postgres migrations

Downloads

4

Readme

PG-Migrations

:triangular_flag_on_post: Currently still being built, use may change slightly until version 1.0.0 is hit, then I will default to semantic versioning as expected. :triangular_flag_on_post:

I built this package after realizing that I had written or reimplemented this code on several occasions. I decided for the purpose observability to not add a way to remove patches. If you need to revert, you should fail forward by adding a new patch to undo the previous changes.

The purpose of this it to allow a history of the db schema and "state" to exist in version control.

Installation

$ npm install pg-migrations

or

$ yarn add pg-migrations

Use

$ pg-migrations path/to/migration.json

You will need to setup a migration-history table. I have included an example in the db folder called migration_history.sql.

CREATE TABLE IF NOT EXISTS patch_history (
  id SERIAL PRIMARY KEY,
  filename TEXT UNIQUE NOT NULL,
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

This gives us a patch_history table that is used to store all applied patches. It is recommendws to include this file in your patchPath folder as it is expected.

The other sql files are expected to have a filename in ISOString() format 2022-03-18T06:22:06.000Z.sql and they will be processed in chronological order based upon this filename timestamp representation.

Example migration.json

{
  // Please remove comments as comments are not part of the 
  // official JSON specification.
  "host": "localhost", // 'localhost' is the default;
  "port": 5432, // 5432 is the default;
  "database": "my-db",
  "user": "postgres",
  "password": "example",

  // to auto-exit on idle, without having to shut-down the pool;
  // see https://github.com/vitaly-t/pg-promise#library-de-initialization
  "allowExitOnIdle": true,
  "patchPath": "./db/" // path to SQL patches relative to where this is called from (usually project root)
};

The other options contained within are the config that is used by pg-promise to connect to your postgres database. I have this exact object embedded as the defaultConfig if you do not pass one in.

I plan to add tests shortly for this and would appreciate any feedback or recommendations.