PostgreSQL Schema Comparison

Compare PostgreSQL
Schemas & Generate Scripts

BaseDiff analyzes two PostgreSQL databases, detects structural differences and generates ready-to-use migration scripts automatically.

base-diff — postgresql
$ basediff compare dev.db prod.db   Comparing PostgreSQL schemas... Found 5 differences   + CREATE TABLE public.audit_log (...); ~ ALTER TABLE public.users ADD COLUMN avatar TEXT; + CREATE INDEX idx_users_email ON public.users(email); + CREATE FUNCTION public.fn_sync() RETURNS void; − DROP TABLE public.legacy_sessions;   ✓ Migration script generated → update_prod.sql

Everything you need for PostgreSQL schema management

BaseDiff fully respects the unique architecture of PostgreSQL — from trigger-function model to extension filtering.

Tables & Columns

Tracks data types including character varying(50), decimal(18,2). Detects nullable, default values, collation and column order. Supports both legacy nextval sequences and modern GENERATED ALWAYS AS IDENTITY (PostgreSQL 10+).

Triggers & Trigger Functions

Analyzes both the trigger definition and the associated trigger function (pg_get_functiondef). Detects timing (BEFORE / AFTER), event scope (INSERT, UPDATE, DELETE, TRUNCATE) and enabled/disabled state.

Functions & Procedures

Distinguishes all PostgreSQL function types via prokind: standard functions (f), procedures (p), aggregate functions (a) and window functions (w). Compares full definitions and parameter signatures.

Constraints

Full support for PRIMARY KEY, FOREIGN KEY (including schema, table and column references), UNIQUE, CHECK (pg_get_expr) and EXCLUSION constraints.

Extension Filtering

Intelligently filters objects from extensions such as PostGIS, Unaccent and TimescaleDB. Automatically ignores system schemas (pg_catalog, pg_toast, information_schema) for a clean comparison.

Indexes

Detects unique and composite indexes using indisunique and indisprimary. Supports multi-column indexes with correct column order.

Views

Compares complete view definitions via pg_get_viewdef. Filters materialized views and views from extensions for a clean result.

Flexible Export

Export to a single file or separate files for CREATE, ALTER, DROP and data migration scripts. Copy to clipboard or save to disk.

Compare schemas in three simple steps

1. Connect databases

Configure source and target PostgreSQL connections. Enter host, port, database name and credentials. Swap source and target with one click.

2. Compare schemas

BaseDiff analyzes both PostgreSQL schemas and displays all differences in a clear tree structure. Review each object and its SQL definition.

3. Generate & export scripts

Review generated migration scripts, edit if needed and export to files. Apply scripts to synchronize your target PostgreSQL database.

See BaseDiff in action

BaseDiff PostgreSQL schema comparison main window with schema trees and SQL update scripts BaseDiff PostgreSQL schema comparison main window with schema trees and SQL update scripts
PostgreSQL schema comparison — main window
BaseDiff PostgreSQL source and target database selection dialog BaseDiff PostgreSQL source and target database selection dialog
Source and target database selection
BaseDiff PostgreSQL migration script export including CREATE ALTER and DROP statements BaseDiff PostgreSQL migration script export including CREATE ALTER and DROP statements
Export migration scripts to files

Start comparing PostgreSQL schemas today

Download BaseDiff for free and generate your first migration script in minutes.

Download for Windows Download for Linux Download for macOS