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

pg-flyway

v1.3.1

Published

Migration tool for PostgreSQL database, NodeJS version of Java migration tool - flyway (not wrapper for https://flywaydb.org/documentation/commandline)

Readme

pg-flyway

Migration tool for PostgreSQL database, NodeJS version of Java migration tool - flyway (not wrapper for flywaydb cli).

npm version monthly downloads

Usage

Starting the database

To start the database, run the following command:

curl -fsSL https://raw.githubusercontent.com/EndyKaufman/pg-tools/refs/heads/master/docker-compose.yml -o docker-compose.yml
docker compose up -d

This will result in a successful PostgreSQL container startup:

[+] Running 3/3
 ✔ Network pg-tools_default              Created                         0.1s
 ✔ Volume "pg-tools-postgre-sql-volume"  Created                         0.0s
 ✔ Container pg-tools-postgre-sql        Started                         0.2s

Creating a migration

To create your first migration, run the following command:

npx pg-flyway create --name=Init --version=1
echo "CREATE TABLE \"User\"(id uuid NOT NULL DEFAULT uuid_generate_v4() constraint PK_USER primary key,email varchar(20));" > migrations/V1__Init.sql

The result will be the successful creation of an empty migration:

[2025-01-15T23:23:53.903] [INFO] CreateEmptyMigrationService - Name: Init
[2025-01-15T23:23:53.904] [INFO] CreateEmptyMigrationService - Locations: migrations
[2025-01-15T23:23:53.914] [INFO] CreateEmptyMigrationService - Migration "migrations/V1__Init.sql" was created successfully!

Applying migration

To apply the created migration, run the following command:

npx pg-flyway migrate --database-url=postgres://postgres:pgtoolspassword@localhost:5432/pgtoolsdatabase?schema=public

The result will be a successful migration:

[2025-01-16T00:08:39.052] [INFO] MigrateService - Locations: migrations
[2025-01-16T00:08:39.053] [INFO] MigrateService - HistoryTable: __migrations
[2025-01-16T00:08:39.053] [INFO] MigrateService - DatabaseUrl: postgres://postgres:pgtoolspassword@localhost:5432/pgtoolsdatabase?schema=public
[2025-01-16T00:08:39.074] [INFO] MigrateService - Migrations: 1

View a list of completed migrations

To view a list of completed migrations, run the following command:

npx pg-flyway info --database-url=postgres://postgres:pgtoolspassword@localhost:5432/pgtoolsdatabase?schema=public

The result will be a table with information about completed migrations:

[2025-01-16T09:15:34.007] [INFO] info - HistoryTable: __migrations
[2025-01-16T09:15:34.008] [INFO] info - DatabaseUrl: postgres://postgres:pgtoolspassword@localhost:5432/pgtoolsdatabase?schema=public
[2025-01-16T09:15:34.057] [INFO] info - Migrations: 1
┌───────────┬─────────┬─────────────┬──────┬─────────────────────┬─────────┬──────────┐
│  Category │ Version │ Description │ Type │        Installed On │   State │ Undoable │
├───────────┼─────────┼─────────────┼──────┼─────────────────────┼─────────┼──────────┤
│ Versioned │       1 │        Init │  SQL │ 2025-01-15 20:08:39 │ Success │       No │
└───────────┴─────────┴─────────────┴──────┴─────────────────────┴─────────┴──────────┘

Stopping the database

To stop the database, run the following command:

docker compose down

This command will stop the container with the PostgreSQL database.

Extended description of commands and their parameters

Create

Create empty migration named by mask VyyyyMMddkkmm__Name.sql (example: V202501151755__Init.sql, Date field symbol table: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table).

Usage: pg-flyway create [options]

Options:
  -n,--name <strings>                    Name the migration
  -v,--version <strings>                 Static version, if the value is not passed, then use the current date and time in the format "yyyyMMddkkmm"
  -l,--locations <strings>               Locations with migration files (default: "migrations", env: PG_FLYWAY_LOCATIONS)
  -s,--sql-migration-suffixes <strings>  Extension of migration files (default: ".sql", env: PG_FLYWAY_SQL_MIGRATION_SUFFIXES)
  --sql-migration-separator <strings>    Version separator (example: V1__Name.sql, sqlMigrationSeparator= "__") (default: "__", env:
                                         PG_FLYWAY_SQL_MIGRATION_SEPARATOR)
  -h, --help                             display help for command

Migrate

Migrates the schema to the latest version.

Usage: pg-flyway migrate [options]

Options:
  -d,--dry-run <boolean>                         Show content of migrations without apply them in database (default: "false", env: PG_FLYWAY_DRY_RUN)
  -c,--config <string>                           Configuration file for bulk migrations (example content:
                                                 [{"databaseUrl":"postgres://${POSTGRES_USER}:POSTGRES_PASSWORD@localhost:POSTGRES_PORT/POSTGRES_DATABASE?schema=public"}], rules: https://github.com/cosmiconfig/cosmiconfig)
                                                 (default: "pgFlyway", env: PG_FLYWAY_CONFIG)
  -u,--database-url <string>                     Database url for connect (example:
                                                 postgres://POSTGRES_USER:POSTGRES_PASSWORD@localhost:POSTGRES_PORT/POSTGRES_DATABASE?schema=public) (default: "",
                                                 env: PG_FLYWAY_DATABASE_URL)
  -l,--locations <strings>                       Locations with migration files (default: "migrations", env: PG_FLYWAY_LOCATIONS)
  -h,--history-table <string>                    History table with states of migration (default: "__migrations", env: PG_FLYWAY_HISTORY_TABLE)
  --history-schema <string>                      History table schema with states of migration (default: "public", env: PG_FLYWAY_HISTORY_SCHEMA)
  -s,--sql-migration-suffixes <strings>          Extension of migration files (default: ".sql", env: PG_FLYWAY_SQL_MIGRATION_SUFFIXES)
  --sql-migration-separator <strings>            Version separator (example: V1__Name.sql, sqlMigrationSeparator= "__") (default: "__", env:
                                                 PG_FLYWAY_SQL_MIGRATION_SEPARATOR)
  --sql-migration-statement-separator <strings>  Separator of nested queries within a sql query (default: "--", env: PG_FLYWAY_SQL_MIGRATION_STATEMENT_SEPARATOR)
  --help                                         display help for command

Info

Prints the details and status information about all the migrations.

Usage: pg-flyway info [options]

Options:
  -u,--database-url <string>   Database url for connect (example:
                               postgres://POSTGRES_USER:POSTGRES_PASSWORD@localhost:POSTGRES_PORT/POSTGRES_DATABASE?schema=public) (env:
                               PG_FLYWAY_DATABASE_URL)
  -h,--history-table <string>  History table with states of migration (default: "__migrations", env: PG_FLYWAY_HISTORY_TABLE)
  --history-schema <string>    History table schema with states of migration (default: "public", env: PG_FLYWAY_HISTORY_SCHEMA)
  --help                       display help for command

Links

https://github.com/EndyKaufman/pg-tools - repository with the project

https://www.npmjs.com/package/pg-flyway - utility on npm

https://documentation.red-gate.com/fd/flyway-concepts-271583830.html - Flyway documentation

https://www.npmjs.com/package/node-flywaydb - wrapper for Flyway (Java) on NodeJS

License

MIT