sql-watch-lib v0.1.0 is a Node.js library for rapid SQL development that automatically applies idempotent SQL scripts to a PostgreSQL database when files change. It supports a watch mode for development and can be integrated into CI/CD pipelines. Unlike full migration tools (e.g., Flyway, Alembic), it focuses on idempotent SQL (CREATE OR REPLACE, etc.) and immediate feedback. Currently in early release with pre-1.0 API changes likely. It ships TypeScript types and is part of the sql-watch monorepo.
npm install sql-watch-libNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a watcher that applies idempotent SQL scripts from ./sql on file changes.
Pin to exact version and test upgrades.
Use 'CREATE OR REPLACE' or 'IF NOT EXISTS' patterns.
Set 'pollInterval' in config or restrict scriptsDir.
Replace 'events: { change: fn }' with 'watcher.on('change', fn)'.Specify a different port in DATABASE_URL, e.g., postgresql://localhost:5433/mydb
Ensure pg client supports SCRAM or use md5 authentication; update pg package.
Use 'import { init } from 'sql-watch-lib'' (ESM) or update tsconfig.json.