Skip to content
Vivek edited this page Jul 14, 2026 · 4 revisions

pg-migration-engine

PostgreSQL schema introspection, diff, DDL generation, and safe migration execution.

Quick Links

Topic Description
Architecture 8-module engine design and data flow
Supported-Objects Full 50+ object types
API-Reference All public methods with parameters
Safe-Migration-Patterns 6+ safe patterns for safe migrations
Risk-Assessment 5-level risk classification system
PG-Version-Matrix Feature support across PG10-18
Testing 6-layer test strategy and results

Why This Engine

No existing open-source tool covers 50+ PostgreSQL object types:

Tool Coverage Limitation
pgAdmin UI only No programmatic API
Atlas ~15 types Missing views, functions, triggers, policies
Prisma ~10 types Ignores behavioral objects

This engine: 50+ types, 190+ properties tracked

Installation

npm install pg-migration-engine

Quick Start

import pg from 'pg';
import { PgMigrationEngine } from 'pg-migration-engine';

const pool = new pg.Pool({ host: 'localhost', database: 'mydb' });
const engine = new PgMigrationEngine();

const snapshot = await engine.introspect(pool);
const diff = engine.diff(desired, snapshot);
const plan = engine.plan(diff);

if (!plan.blocked) {
  await engine.execute(pool, plan);
}

License

Business Source License 1.1 (BSL) — free for development, commercial license required for production.

Built by Schema Weaver.

Clone this wiki locally