Skip to main content
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:
  1. Gradual Migration - Incrementally adopt pgschema without managing all existing objects
  2. Temporary Objects - Exclude temp tables, debug views, and development-only objects
  3. Legacy Objects - Ignore deprecated objects while maintaining new schema management
  4. Environment-Specific Objects - Skip objects that exist only in certain environments

File Format

The .pgschemaignore file is automatically loaded when present in the current directory:
Create a .pgschemaignore file in your project directory using TOML format:
[tables]
patterns = ["temp_*", "test_*", "!test_core_*"]

[views]
patterns = ["debug_*", "*_view_tmp", "analytics_*"]

[functions]
patterns = ["fn_test_*", "fn_debug_*"]

[procedures]
patterns = ["sp_temp_*", "sp_legacy_*"]

[types]
patterns = ["type_test_*"]

[sequences]
patterns = ["seq_temp_*", "seq_debug_*"]

Pattern Syntax

Wildcard Patterns

Use * to match any sequence of characters:
[tables]
patterns = [
  "temp_*",        # Matches: temp_backup, temp_cache, temp_session
  "*_backup",      # Matches: users_backup, orders_backup
  "test_*_data"    # Matches: test_user_data, test_order_data
]

Exact Patterns

Specify exact object names without wildcards:
[tables]
patterns = ["legacy_table", "deprecated_users", "old_audit"]

Negation Patterns

Use ! prefix to exclude objects from broader patterns:
[tables]
patterns = [
  "test_*",           # Ignore all test_ tables
  "!test_core_*"      # But keep test_core_ tables
]
This will ignore test_data, test_results but keep test_core_config, test_core_settings.

Triggers on Ignored Tables

Triggers can be defined on ignored tables. The table structure is not managed, but the trigger itself is.
# .pgschemaignore
[tables]
patterns = ["external_*"]
-- schema.sql
CREATE TRIGGER on_data_change
  AFTER INSERT ON external_users
  FOR EACH ROW
  EXECUTE FUNCTION sync_data();
The trigger will be managed while external_users table structure remains unmanaged.