sql-patch is a minimal, idempotent SQL migration tool for Node.js, version 1.2.2. It applies all `.sql` files in a directory in order to a PostgreSQL database, tracking applied patches in a `_schema_patches` table. Unlike Rails migrations, patches are one-way and SQL-only, with no DSL or ORM. Release cadence is low; the project is stable but limited to PostgreSQL. Key differentiator: extremely simple, no configuration, and pure SQL — no code generation or rollbacks.
npm install sql-patchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use sql-patch programmatically with sqlcmd-pg to create a database and apply all .sql migrations from a directory.
Always append new patches instead of editing existing ones. Rollbacks must be handled manually.
Install sqlcmd-pg and use its Connection class.
Manually wrap patches in BEGIN/COMMIT within the SQL file, or use a different tool for transactional guarantees.
Use `import sqlPatch from 'sql-patch'` or set type: 'module' in package.json and use dynamic import if needed.
Use `const sqlPatch = require('sql-patch');` or `import * as sqlPatch from 'sql-patch';`Ensure PostgreSQL is running and update connection parameters (host, port, user, password).