pgpm

A Postgres Package Manager

The open-source Postgres package manager and migration engine, built by Constructive. Ship schemas, roles, policies and functions as versioned modules, then deploy, verify and revert them in plain SQL.

Postgres Modules

Versioned packages of schemas, roles, policies and functions

Dependency Resolution

Modules require modules, resolved recursively like npm

Deploy, Verify, Revert

Every change ships with its own verify and revert script

pgpm Features

Migrations and packages for Postgres, in plain SQL

Postgres Module System

Reusable, composable database packages with per-module plans, dependency management and versioned releases.

Deterministic Migrations

Plan-driven deployments with rollback support and idempotent execution, guarded by dependency and validation checks.

Recursive Module Resolution

Resolves dependencies from plan files or SQL headers into one reproducible, cross-module migration graph.

Tag-Aware Versioning

Deploy to a tag, resolve tags to changes, and reference tags across modules for coordinated releases.

Portable Postgres

Standard SQL migrations that run anywhere Postgres does, from Docker on a laptop to production.

Turnkey Workspaces

pgpm init creates a ready-to-code workspace with CI/CD, Docker, end-to-end tests and TypeScript tooling.

bash
npm install -g pgpm

pgpm docker start
eval "$(pgpm env)"

pgpm init workspace
cd my-app
pgpm init
cd packages/your-module

pgpm install @pgpm/faker
pgpm deploy --createdb --database mydb1
psql -d mydb1 -c "SELECT faker.city('MI');"

Start Postgres and a Workspace

Start a local Postgres in Docker, create a workspace and a module, install a published module and deploy it all.

bash
pgpm add some_change   # deploy/, revert/ and verify/ scripts + a plan entry

pgpm deploy --createdb
pgpm verify
pgpm revert

Add a Change

Each change gets deploy, revert and verify scripts and a place in the plan. Deploy it, verify it, revert it.