Registry / database / immigration-postgres

immigration-postgres

JSON →
library2.0.0jsnpmunverified

PostgreSQL adapter for Immigration, a database migration tool. Version 2.0.0 is current stable; the adapter automatically manages a migration tracking table and connects to Postgres via the `pg` library's Pool. It integrates with Immigration's CLI and programmatic API, allowing users to specify connection config via file or inline Pool options. Differentiator: lightweight, no ORM dependency.

npm install immigration-postgres
INSTALL
IMPORT
SIG · IMMIGRATION-POSTGR
I
immigration-postgres
databasejavascriptv2.0.0
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.

createAdapter
import { createAdapter } from 'immigration-postgres'
const createAdapter = require('immigration-postgres')
Package is ESM-only; requires Node with ESM support
default
import pgAdapter from 'immigration-postgres'
const pgAdapter = require('immigration-postgres').default
Default export is same as createAdapter
ImmigrationConfig
import type { ImmigrationConfig } from 'immigration-postgres'
Type export for configuration object

Shows how to instantiate the adapter with a connection string and run migrations.

import { createAdapter } from 'immigration-postgres'; import { Immigration } from 'immigration'; const adapter = createAdapter({ table: 'migrations', connectionString: process.env.DATABASE_URL ?? '' }); const immigration = new Immigration( { directory: './migrations' }, adapter ); await immigration.up();
Debug
Known issues
breakingImmigration v2 changed the adapter API; createAdapter() no longer returns a constructor.
fix
Use createAdapter(options) directly instead of new Adapter(options).
affects: >=2.0.0
deprecatedPassing Pool options via config file is deprecated; use inline Pool options instead.
fix
Move Pool options to the adapter constructor arguments.
affects: >=1.5.0
gotchaThe 'table' option is required; adapter silently creates it on first run.
fix
Always specify table name in options.
affects: >=1.0.0
gotchaEscape backticks in SQL: adapter uses template literals; unescaped user input may cause injection.
fix
Use parameterized queries or validate migration names.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'immigration-postgres'
Missing npm install or incorrect import path
fix
Run npm install immigration immigration-postgres
TypeError: createAdapter is not a function
ESM import incorrectly using require() instead of import
fix
Use import { createAdapter } from 'immigration-postgres'
error: relation "migrations" does not exist
Table not created because adapter options.table missing
fix
Provide table name in adapter options: { table: 'migrations' }
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
immigrationrequiredPeer dependency: core migration framework required at runtime
Agent activity
8 hits · last 30 days
node
8
Resources
immigration-postgres — npm install immigration-postgres · libregistry