pgmold

PostgreSQL schema-as-code in plain SQL, with safety linting and drift checks

Image 1 of 1: pgmold site with a migration plan of three operations in a terminal

A Rust CLI that parses native DDL files and a live database into one canonical model and emits only the delta, covering partitions, RLS policies, grants and ownership. Plans reverse for rollback, drift reports as JSON for CI, and apply runs in one transaction.

Trade-offs

  • Renames are not detected: two snapshots can't tell a rename from a drop and an add, and a wrong guess destroys data, so a rename is applied to the database by hand first.
  • Destructive operations need --allow-destructive, type narrowing and SET NOT NULL warn, and PGMOLD_PROD=1 blocks table drops entirely.
  • Parser matches on sqlparser enums never end in a wildcard arm, so each new upstream variant needs explicit triage; a wildcard once dropped column-level constraints for months.

Q&A2

pgmold drift -j compares the schema files with the live database and returns a JSON report, exiting 1 when they differ.

Reviews

Loading reviews

    More in Migrations

    See all 7 →
    • PaganelData migration engine that verifies the destination down to the row
    • MigrationPilotPostgreSQL migration linter that blocks unsafe DDL before merge
    • pistachioDeclarative PostgreSQL schema management with a plan and apply workflow
    • FlydbVersioned database migrations with a local GUI, a CLI and agent hand-off
    • dbconformFinds and repairs drift between a SQL database and its SQLAlchemy models
    • terradbDeclarative schema management for PostgreSQL and SQLite

    More in Postgres

    See all 25 →
    • SupermetryCookie-free web and product analytics on one Go binary and PostgreSQL
    • arbiterPostgreSQL job queue for Haskell, with no broker and no leader
    • StreambedPostgres-to-Iceberg CDC engine with a built-in Postgres wire query server
    • go-ledgerMulti-tenant double-entry payment ledger API in Go, built in public
    • RRQClosed-loop payment ledger on sharded Postgres with a Kafka outbox
    • pgledgerDouble-entry ledger implemented entirely in PostgreSQL functions and views

    More in CLI tools

    See all 74 →
    • ZeroboxDeny-by-default process sandbox with per-host secret injection
    • blitcpFile copier that reads in disk order, dedupes and streams over raw SSH
    • jc-rsjc rewritten as one static binary that turns command output into JSON
    • quiverDump, load, copy and stream MySQL, MariaDB and TiDB from one consistent snapshot
    • haxMinimalist terminal coding agent written in C
    • roam-codeLocal code index and checks that coding agents can query