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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pg-upgrade

v0.1.5

Published

Postgreqsl Schema Upgrade

Downloads

3

Readme

pg-upgrade

Postgresql Schema Upgrade

NOTE: This is an experimental package and not supported in any way!

This utility runs a series of schema upgrade scripts in order, and then runs all stored routines, ensuring that the target database is up to date with all schema changes. It includes a useful testing option that creates a new empty database and runs all scripts on it, which can be used as part of CI/CD pipelines to make sure newly submitted changes are compatible with the existing schema.

Usage

Export environment variables PGHOST, PGUSER, PGPORT, PGDATABASE, PGSCHEMA. Store your password in ~/.pgpass (See (https://www.postgresql.org/docs/current/libpq-pgpass.html)[https://www.postgresql.org/docs/current/libpq-pgpass.html]).

npm install pg-upgrade
npx pg-upgrade init 
npx pg-upgrade show -f path/to/directory

Files in the directory should be in the format YYYY-MM-DD-HH-mm-Description.sql, e.g. '2022-06-10-13-00-AddNewColumn.sql`.

(The minimal requirement is 0000-00-00.sql, which means you could use invalid dates and simply increment the numbers, but it's nice to have a date on every change with a short description so you can remember when you made the change and why you made it.)

Inside that folder you may have another folder called procedures. Scripts in that folder do not have a naming convention, and they will all be run each time this script is invoked.

Sample structure:

    ./schema    
        2022-06-10-01-01-Initial.sql
        2022-06-10-02-00-AddSomething.sql
        procedures/
            user_get.sql
            user_save.sql
            user_delete.sql
            users_list.sql

Options

Usage: pg-upgrade [options] [command]

Postgresql Schema Upgrade

Options:
  -V, --version              output the version number
  -v, --verbose              Output verbose statements to the console
  -f, --folder [folder]      The folder where change scripts are stored
  -h, --host [host]          Database host (or PGHOST environment variable)
  -d, --database [database]  Database name (or PGDATABASE environment variable)
  -s, --schema [schema]      Database schema (or PGSCHEMA environment variable)
  -p, --port [port]          Database port (or PGPORT environment variable)
  -u, --user [user]          Database user (or PGUSER environment variable). Password must be in .pgpass
  --help                     display help for command

Commands:
  run                        Run the changes
  show                       Show the changes that will be made with the run command
  test [options]             Create a test database and run all schema changes
  init                       Create the schema_change table in your database to track changes
  help [command]             display help for command