PostgreSQL migration tool using advisory locks for safe concurrent execution. Version 1.1.2 is the latest stable release with low maintenance cadence. Executes .sql migration files sequentially with automatic locking to prevent race conditions. Minimal configuration, supports custom reporters and connection strings. Differentiates from alternatives like node-pg-migrate by its simplicity and reliance on PostgreSQL advisory locks.
npm install postgres-migrateNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal setup to run SQL migrations from a directory against a PostgreSQL database using connection string from environment variables.
Ensure all migration files have .sql extension and no other files in the directory.
Use an existing pg client instance or switch to 'client' option if supported.
Upgrade PostgreSQL to 9.4 or later.
Check the 'reporter' function logs for detailed error messages.
Implement a manual timeout or use a monitoring tool to release stale locks.
Start PostgreSQL service and verify connection string.
Create the migrations table manually: CREATE TABLE IF NOT EXISTS migrations (id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE, run_on TIMESTAMP DEFAULT NOW());
Use const migrate = require('postgres-migrate') (not destructured).Check that the migrations directory path is absolute or relative to working directory.
Grant necessary privileges: GRANT CREATE ON SCHEMA public TO <user>;