PgDesigner

PostgreSQL Schema Diff & Migrations

Two schemas in, safe ALTER migration out — with hazard warnings before anything hits production.

PgDesigner Diff dialog showing unsaved changes with DROP, ADD, ALTER badges and hazard warnings (DELETES_DATA, TABLE_REWRITE) in light theme

Stop writing ALTER by hand

Every migration tool generates ALTER TABLE. Few tell you that your ALTER COLUMN TYPE will lock the table for 20 minutes, or that ADD COLUMN NOT NULL without a DEFAULT will fail on existing rows. PgDesigner does both — generates the SQL and warns you about the risks.

How the diff engine works

Give it two .pgd models — old and new. The engine computes every structural change and emits safe ALTER statements in the correct dependency order.

Phase 1 — DROP

Reverse dependency order: FK → indexes → columns → tables. Nothing breaks because dependents are removed first.

Phase 2 — CREATE / ALTER

Forward dependency order: enums → tables → columns → PK → indexes → FK. References always exist before they're needed.

Four ways to diff

Model vs Model

Edit your .pgd, get the migration script instantly.

DB vs Model

pg_dump → convert → compare with your model.

Git versions

Two versions of .pgd from git history → ALTER patch.

Live preview

Press Ctrl+D to see ALTER SQL for unsaved changes.

Hazard detection — know the risks before you deploy

Every generated ALTER is analyzed for operational hazards. The diff engine emits a comment with the hazard level and code directly before the SQL statement.

DELETES_DATA DROP TABLE, DROP COLUMN — permanent data loss, requires confirmation
TABLE_RECREATE Adding, removing, or changing PARTITION BY strategy — requires full table rebuild
TABLE_REWRITE ALTER COLUMN TYPE with incompatible cast — may rewrite the entire table on disk
BACKFILL_REQUIRED ADD COLUMN NOT NULL without DEFAULT or IDENTITY — existing rows have no value
DETACH_PARTITION Partition removed from list — will be detached from the parent table
REATTACH_PARTITION Partition bounds changed — DETACH then re-ATTACH with new bounds

Compatible type casts (varchar(N)varchar(M), integerbigint, smallintinteger) are recognized as safe and don't trigger TABLE_REWRITE.

Smart rename detection

Renamed an index or foreign key? PgDesigner compares the structural definition (table, columns, method) — not just the name. If the structure is identical, it skips the drop+add cycle. Only actual structural changes trigger recreation.

What gets diffed

Tables (including comment and PARTITION BY), columns (type, nullable, default, identity with sequence options, comment, compression, storage), indexes, FK, PK, UNIQUE, CHECK constraints, enum values (ADD VALUE), and partitions (CREATE, DETACH, re-ATTACH on bound change). Views and functions diff is planned for Phase 2.

CLI

pgdesigner diff old.pgd new.pgd
pgdesigner diff old.pgd new.pgd -o migration.sql

Press Ctrl+D in the UI for a live diff preview with hazard badges — red for dangerous, yellow for warnings.