A minimal migration manager for PostgreSQL using the pg driver. Version 1.0.12 is the latest stable release. It reads SQL files from a specified directory and runs them sequentially based on file creation dates, tracking executed migrations in a database table. Unlike heavier tools (e.g., node-pg-migrate), it stays simple with no dependency on query builders or complex configuration. Ships TypeScript types, ESM-only. Ideal for projects that need bare-bones SQL migration management.
npm install pg-migration-managerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to PostgreSQL using pg Pool, runs pending SQL migrations from a directory, then closes the pool.
Use ESM imports: import MigrationManager from 'pg-migration-manager'; or wrap in dynamic import().
Ensure file creation dates reflect desired order (e.g., touch files in order).
Never rename migration files after they have been applied. Mark changes with new files.
Write each migration file as a single transactional SQL statement (BEGIN/COMMIT) to ensure atomicity.
Use import MigrationManager from 'pg-migration-manager'; or convert your file to ES module.
Use import MigrationManager from 'pg-migration-manager'; without destructuring.
Ensure a valid pg Pool or Client is passed, and don't close the pool until after runMigrations resolves.