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

cbpgm

v0.1.5-alpha

Published

Charper Bonaroo's PostGres Migrate tool

Downloads

15

Readme

Charper Bonaroo's PostGres Migrate tool

Screw DSLs. Write migrations using plain SQL.

Examples:

cbpgm init cbpgm recreate cbpgm migrate

Commands:

recreate Fastest way to start fresh: Drop if exists, then create and migrate

migrate Create database if not exists, then run the up.sql files for the migrations and add them to the list of completed migrations, sorted naturally. Accepts migration IDs to rollback individual migrations, otherwise runs all migrations.

up Alias for migrate

rollback Run down.sql (if exists) for all migrations executed in the last migrate-call (even if the folder had no up.sql file) in reverse order. Requires migration IDs to rollback individual migrations, or --last to rollback the last migration.

down Alias for rollback

init Create the .cbpgm.js config file & migrations directory config Print the current postgres config help Render this help-text list Print the list of migrations and their status

createdb Create the postgres database (without migrations) create Alias for createdb

dropdb Delete the postgres database. drop Alias for dropdb

This tool allows you to write migration scripts in plain SQL. You create your migration by creating a folder containing a up.sql and down.sql file. The migrations (i.e. the up.sql files) will be executed in their containing folder's natural sort order. Migrations will only be executed once unless they've been rolled back. The up.sql and down.sql aren't both required, but one of them should exist. Alternatively, if you only need an up.sql, you can also use an .sql file directly in the migrations root folder. E.g. creating a 123-foo.sql file has the same effect as creating a 123-foo/up.sql file without a down.sql file.

Sorting of migrations is done using a NATURAL ORDER. Natural sorting is the ordering of strings in alphabetical order, except that multi-digit numbers are treated atomically, i.e., as if they were a single character.

Example folder structure (naturally sorted):

migrations/ 1-add-users/ up.sql down.sql 2-add-posts/ up.sql down.sql 3-add-comments/ up.sql down.sql 12-add-categories.sql 13-add-votes/ up.sql down.sql 101-add-reports/ up.sql down.sql

If you're running this command from the repo, you can use ./cli.js instead of cbpgm.