Skip to content

Filtering Objects

Filter which objects are compared and migrated using name patterns and object types.

Terminal window
# Include only objects matching patterns
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--include 'api_*' --include 'users'
# Exclude objects matching patterns
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--exclude '_*' --exclude 'pg_*'
Terminal window
# Only compare tables and functions
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--include-types tables,functions
# Exclude extensions from comparison
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--exclude-types extensions
Terminal window
# Compare only functions matching 'api_*', excluding internal ones
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--include-types functions \
--include 'api_*' \
--exclude '_*'
Terminal window
# Compare tables without RLS policies
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--exclude-types policies
# Compare only table structure (no indexes, constraints, or policies)
pgmold plan -s sql:schema.sql -d postgres://localhost/mydb \
--exclude-types policies,indexes,foreignkeys,checkconstraints

Top-level: extensions, tables, enums, domains, functions, views, triggers, sequences, partitions

Nested (within tables): policies, indexes, foreignkeys, checkconstraints

By default, pgmold excludes objects owned by extensions (e.g., PostGIS functions, pg_trgm operators) from diffs.

Terminal window
# Include extension objects if needed
pgmold dump -d postgres://localhost/mydb --include-extension-objects -o full_schema.sql