Registry / database / migrat-postgres

migrat-postgres

JSON →
library0.2.0jsnpmunverified

Official PostgreSQL adapter for the Migrat database migration tool (v0.2.0). Provides global locking and migration state storage/retrieval using PostgreSQL. Enables writing migrations in pure PSQL. Compatible with Migrat v0.x. Integrates with Migrat's plugin system and supports custom schema/table configuration. Key differentiator: allows pure SQL migrations instead of JavaScript.

npm install migrat-postgres
INSTALL
IMPORT
SIG · MIGRAT-POSTGRES
M
migrat-postgres
databasejavascriptv0.2.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.

default export
const postgres = require('migrat-postgres');
import postgres from 'migrat-postgres';
CJS only; no ESM support.
plugin configuration
module.exports = { plugins: [postgres({ host: 'localhost', database: 'mydb' })] };
module.exports = { plugins: [postgres] };
postgres() must be called with config object, not passed as constructor.
require with destructuring
const postgres = require('migrat-postgres');
Module exports a single function; no named exports.

Configuration file for Migrat with PostgreSQL adapter, using env vars for credentials.

// Install: npm install migrat migrat-postgres // Create migrat.config.js: const postgres = require('migrat-postgres'); module.exports = { plugins: [ postgres({ host: process.env.PGHOST || 'localhost', port: parseInt(process.env.PGPORT || '5432'), user: process.env.PGUSER || 'postgres', password: process.env.PGPASSWORD || '', database: process.env.PGDATABASE || 'mydb', migratSchema: process.env.MIGRAT_SCHEMA || 'public', migratTable: process.env.MIGRAT_TABLE || 'migrat', enableLocking: true, enableStateStorage: true }) ] }; // Run: npx migrat migrate
Debug
Known issues
gotchaThe adapter requires the 'migrat' package as a peer dependency; it does not work standalone.
fix
Ensure migrat is installed: npm install migrat
affects: >=0.0.0
gotchaPlugin configuration must call postgres() with a config object; passing the function directly will fail.
fix
Use postgres({...}) not postgres alone.
affects: >=0.0.0
gotchaMigration files must include comments '-- up:', '-- down:', and '-- check:' for proper parsing.
fix
Include the required comment markers in SQL migrations.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'migrat'
Missing peer dependency 'migrat'.
fix
npm install migrat
TypeError: postgres is not a function
Using import statement instead of require() — CJS only.
fix
Replace import with const postgres = require('migrat-postgres');
Error: postgres is not a function
Passing postgres (function) directly instead of calling postgres(config).
fix
Change plugins: [postgres] to plugins: [postgres({...})]
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
migrat-postgres — npm install migrat-postgres · libregistry