pgschema supports ignoring specific database objects using a .pgschemaignore file, enabling gradual onboarding and selective schema management.
Overview
The.pgschemaignore file allows you to exclude database objects from pgschema operations. This is particularly useful when:
- Gradual Migration - Incrementally adopt pgschema without managing all existing objects
- Temporary Objects - Exclude temp tables, debug views, and development-only objects
- Legacy Objects - Ignore deprecated objects while maintaining new schema management
- Environment-Specific Objects - Skip objects that exist only in certain environments
- Role-Specific Privileges - Ignore grants to roles that don’t exist in the plan database
File Format
The
.pgschemaignore file is automatically loaded when present in the current directory:.pgschemaignore file in your project directory using TOML format:
Pattern Syntax
Wildcard Patterns
Use* to match any sequence of characters:
Exact Patterns
Specify exact object names without wildcards:Negation Patterns
Use! prefix to exclude objects from broader patterns:
test_data, test_results but keep test_core_config, test_core_settings.
Privileges
The[privileges] and [default_privileges] sections filter GRANT statements by grantee role name. This is useful when running pgschema plan with roles that don’t exist in the plan database, or managing migrations across environments with different role configurations.
[privileges] section filters explicit grants (GRANT ... TO role), including column-level privileges. The [default_privileges] section filters ALTER DEFAULT PRIVILEGES statements.
Constraints
The[constraints] section matches table constraints by constraint name (primary keys, unique, foreign keys, check, and exclusion constraints). When a constraint is ignored, pgschema neither creates, drops, nor reports drift on it — it is left entirely to be managed out-of-band.
- Out-of-band constraints - A constraint is added and managed manually (e.g. disabled during an AWS DMS migration and re-added afterward), and you don’t want
pgschema planto flag it for drop. - Cross-schema foreign keys - When modules live in separate schemas with foreign keys between them, ignore the cross-schema foreign keys so each schema can be bootstrapped independently, then drop the ignore to let pgschema manage them once all tables exist.
Triggers
The[triggers] section matches triggers by trigger name. When a trigger is ignored, pgschema neither creates, drops, nor reports drift on it — it is left entirely to be managed out-of-band.
_vectorizer_src_trg_* triggers to source tables; ignoring them keeps pgschema plan from flagging them for drop while you continue to manage the rest of the table.
Triggers on Ignored Tables
Triggers can be defined on ignored tables. The table structure is not managed, but the trigger itself is.external_users table structure remains unmanaged.
