A transaction-based PostgreSQL schema migration helper for node-postgres (pg). Current stable version is 0.5.2, with no active release cadence (last update years ago). Unlike file-based patch trackers, pg-patcher stores the patch level inside a database table, ensuring consistency across multiple servers. Patch files are plain SQL with a naming convention (patch-{from}-{to}.sql), and migrations can go forward or backward. Notable: first patch must create the property table and set the initial level. Cannot be used with pool connections—requires a single client with an open connection.
npm install pg-patcherNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to PostgreSQL and applies patch files to migrate database to version 2.
In patch-0-1.sql: CREATE TABLE property (key TEXT PRIMARY KEY, value TEXT); INSERT INTO property(key, value) VALUES('patch', 1);Create a pg.Client, call client.connect() before passing to pgpatcher.
Name files exactly as expected, or set custom prefix via options.
Consider alternatives like node-pg-migrate or postgrator for active development.
Ensure db/patch-0-1.sql contains CREATE TABLE property (...) and INSERT INTO property VALUES('patch', 1).Start PostgreSQL or correct host/port/user/database in client configuration.
Run npm install pg-patcher (or yarn add pg-patcher).