Registry / database / sql-migrate-up

sql-migrate-up

JSON →
library4.2.1jsnpmunverified

sql-migrate-up v4.2.1 is a simple SQL migration tool for Node.js with support for SQLite, PostgreSQL, and Snowflake. It provides a CLI and programmatic API (both fp-ts and Promise-based) for running, testing, and creating migrations. Key features: run-once vs. run-always migrations, schema/table configuration, parameter passing, and optional SQL syntax checking via sql-parser-cst. Released under MIT license, with stable release cadence on npm. Differentiates from other migration tools by its minimalism, first-class TypeScript support, and functional programming approach using fp-ts.

npm install sql-migrate-up
INSTALL
IMPORT
SIG · SQL-MIGRATE-UP
S
sql-migrate-up
databasejavascriptv4.2.1
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.

cli
import { cli } from 'sql-migrate-up'
const cli = require('sql-migrate-up').cli
CommonJS require works but TypeScript/ESM preferred. Requires fp-ts peer dependency.
cliPromise
import { cliPromise } from 'sql-migrate-up'
import cliPromise from 'sql-migrate-up'
Named export, not default export. For Promise-based API without fp-ts.
types
import { MigrateConfig } from 'sql-migrate-up'
TypeScript types are included. Use for config types like MigrateConfig or CliConfig.

Configures and runs the migration CLI programmatically using the Promise API. The example sets up schema, folder, and table, and implements select/execute/end callbacks with a database client.

import { cliPromise } from 'sql-migrate-up'; import { withDbClient } from './client'; // your DB client factory const db = withDbClient(); cliPromise({ schema: 'public', folder: './migrations', table: 'migrations', parameters: ({ schema }) => Promise.resolve({ schema }), select: <T>(sql: string) => Promise.resolve(db.select<T>(sql)), execute: (sql) => new Promise((resolve) => { db.exec(sql); resolve(); }), end: () => Promise.resolve(db.end()), });
Debug
Known issues
gotchaThe `folder` option can be a string or a function returning a string. Ensure it returns a valid path.
fix
Use a string like './migrations' or a function `(schema) => 'migrations/' + schema`.
affects: >=4.0.0
deprecatedIn older versions (<4.0.0), the config options were structured differently. The current API expects `schema`, `folder`, `table`, `parameters`, `select`, `execute`, `end` in a single object.
fix
Upgrade to v4+ and refactor config object. See migration guide in GitHub releases.
affects: <4.0.0
gotchaThe `parameters` callback receives an object `{ schema }` which is the schema name as string. Ensure your SQL uses schema-qualified names correctly.
fix
Use `parameters: ({ schema }) => TE.of({ schema })` (fp-ts) or `Promise.resolve({ schema })` (promise).
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: cli is not a function
Importing default export instead of named export
fix
Use `import { cli } from 'sql-migrate-up'`
Cannot find module 'fp-ts'
Missing peer dependency fp-ts when using the fp-ts based `cli`
fix
Install fp-ts: `npm install fp-ts`
Error: No folder specified
The `folder` option is required in the config object but was omitted
fix
Add `folder: './migrations'` to the config object
SyntaxError: Unexpected token 'export'
Using ES module syntax in a CommonJS environment with older Node version
fix
Set `"type": "module"` in package.json, or transpile with Babel/TypeScript
Upgrade
Version history
4.2.1latest on npm
Audit
Dependencies
fp-tsoptionalRequired when using the fp-ts based `cli` function for TaskEither-based effects.
Agent activity
31 hits · last 30 days
node
26
Meta
1
OpenAI (training)
1
Resources
sql-migrate-up — npm install sql-migrate-up · libregistry