Registry / database / sql-migrations-node

sql-migrations-node

JSON →
library1.0.5jsnpmunverified

Minimal raw SQL migration runner for Node.js that supports PostgreSQL and MySQL. Version 1.0.5 (last release appears to be 2018) is a low-activity library focused on raw SQL files and a simple CLI. Unlike Knex or Sequelize migrations, this library has zero ORM dependencies and uses plain SQL files with up/down pairs. It provides programmatic API (migrate, rollback, create) with promise support, configurable logger, optional SQL parameter substitution, and min migration timestamp filtering. Lacks built-in seeding or advanced features; maintained but no recent updates.

npm install sql-migrations-node
INSTALL
IMPORT
SIG · SQL-MIGRATIONS-NOD
S
sql-migrations-node
databasejavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

run
const run = require('sql-migrations').run;
import { run } from 'sql-migrations';
This library uses CommonJS, not ESM. Using import will fail.
migrate
const migrate = require('sql-migrations').migrate;
Programmatic API, returns a Promise.
rollback
const rollback = require('sql-migrations').rollback;
Programmatic API, returns a Promise.
setLogger
require('sql-migrations').setLogger({ log() {}, error() {} });
Must be called before run/migrate/rollback.

Shows basic setup using CommonJS require with environment variables for config and adapter selection.

const path = require('path'); const { run } = require('sql-migrations'); run({ migrationsDir: path.resolve(__dirname, 'migrations'), host: process.env.DB_HOST || 'localhost', port: parseInt(process.env.DB_PORT || '5432', 10), db: process.env.DB_NAME || 'myapp', user: process.env.DB_USER || 'user', password: process.env.DB_PASSWORD || '', adapter: 'pg' }); // CLI: node migrate.js migrate // node migrate.js rollback // node migrate.js create my_migration
Debug
Known issues
gotchaPackage is CommonJS only; ESM import will fail.
fix
Use require() instead of import.
affects: >=1.0
gotchaAdapter packages (pg, mysql) must be installed separately; not listed as peer dependencies.
fix
npm install pg or npm install mysql alongside sql-migrations.
affects: >=1.0
gotchaThe database must exist before running migrations; no automatic creation.
fix
Create the database manually before running migrations.
affects: >=1.0
deprecatedLibrary has not been updated since 2018; bugs may remain unpatched.
fix
Consider using an actively maintained migration tool like node-pg-migrate or Knex.
affects: 1.0.5
gotchaConfiguration requires absolute path for migrationsDir; relative paths fail silently.
fix
Use path.resolve(__dirname, 'migrations') instead of a relative string.
affects: >=1.0
Errors
Common errors & fixes
TypeError: require(...).run is not a function
Using import instead of require, or omitting .run suffix.
fix
Use const { run } = require('sql-migrations');
Error: Cannot find module 'pg'
PostgreSQL adapter not installed.
fix
Run: npm install pg
Error: relation "migrations" does not exist
Migrations table not created yet; first migration must create it.
fix
Ensure the first migration SQL creates the 'migrations' table as per docs (or manually create it).
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
pgoptionalRequired if using PostgreSQL adapter (adapter: 'pg')
mysqloptionalRequired if using MySQL adapter (adapter: 'mysql')
Agent activity
13 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
sql-migrations-node — npm install sql-migrations-node · libregistry