pg-migrator is a command-line tool for PostgreSQL database migrations, version 2.0.1. It supports forward and backward migrations, step-by-step or to a specific version, with transactional (all-or-nothing) execution. It searches subfolders for SQL scripts named in 'x-y.sql' format. Compared to other tools like Flyway or node-pg-migrate, it is simpler, purely CLI-based, and does not require a configuration file beyond the connection string. Its release cadence is low (last release 2019), but it remains functional for basic migration needs.
npm install pg-migratorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Global install, run migration with connection string, optionally specify version or step forward/backward.
Rename files to match pattern. Ensure forward and backward scripts exist for each version.
Ensure each script is transactional-safe (no VACUUM, CREATE INDEX CONCURRENTLY, etc.)
Use complete connection string including port if non-default.
Check README GitHub for CLI options.
Create the required 'x-y.sql' file in the current directory or subfolders.
Verify credentials and ensure the user has access to the database.
Order scripts correctly: create tables in earlier version scripts before using them in later ones.