A simple Node.js library for running raw SQL database migrations. Current stable version is 1.0.7, with infrequent releases. It supports PostgreSQL and MySQL via the 'pg' and 'mysql' npm packages as runtime adapters. Key differentiators include a simple file-based migration system, CLI and programmatic API, customizable parameter substitution in SQL scripts, and optional migration time filtering. Suitable for projects that prefer plain SQL over ORM-based migrations.
npm install sql-migrationsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to run database migrations programmatically using the pg adapter.
Ensure migration filenames start with a 13-digit Unix timestamp followed by underscore.
Manually create the database before running migrations.
Sanitize or validate parameters before passing them.
Use setLogger() to provide a custom logger with log and error methods.
Pass new Date('2018-01-01').getTime() instead of the Date object directly.Provide migrationsDir: path.resolve(__dirname, 'migrations') in config.
Run: npm install pg
Ensure migrationsDir is correct and migration files exist.