Skip to content

Configuration

pgmt uses pgmt.yaml for project configuration. CLI arguments override config file values.

databases:
dev_url: postgres://localhost/myapp_dev
shadow:
auto: true
databases:
dev_url: postgres://localhost/myapp_dev # Development database (required)
target_url: postgres://prod/myapp # Target for migrate apply (optional)
shadow:
auto: true # Auto-create shadow database (recommended)
# OR manual:
# url: postgres://localhost/myapp_shadow
# OR Docker with specific version:
# docker:
# version: '16' # PostgreSQL version
# auto_cleanup: true # Clean up container after use
directories:
schema_dir: schema # Schema files
migrations_dir: migrations # Migration files
baselines_dir: schema_baselines # Baseline snapshots
roles_file: roles.sql # Roles for shadow database
objects:
include:
schemas: ['public', 'app'] # Only manage these schemas
tables: ['users', 'orders'] # Only manage these tables
exclude:
schemas: ['pg_*', 'information_schema'] # Glob patterns supported
tables: ['cache_*', 'temp_*']
comments: true # Manage object comments
grants: true # Manage permissions
triggers: true # Manage triggers
extensions: true # Manage extensions
migration:
default_mode: safe_only # safe_only | confirm_all | force_all
validate_baseline_consistency: true
create_baselines_by_default: false # On-demand (recommended)
tracking_table:
schema: public
name: pgmt_migrations
schema:
augment_dependencies_from_files: true # Use -- require: directives
validate_file_dependencies: true
docker:
auto_cleanup: true
check_system_identifier: true
Terminal window
PGMT_CONFIG_FILE # Override config file location
PGMT_DEV_URL # Override dev database URL
PGMT_SHADOW_URL # Override shadow database URL
PGMT_TARGET_URL # Override target database URL

Use ${VAR} syntax in config files to reference environment variables:

databases:
dev_url: ${DEV_DATABASE_URL}
target_url: ${PROD_DATABASE_URL}
Terminal window
pgmt apply --dev-url postgres://localhost/other_db
pgmt apply --schema-dir custom_schema/
pgmt apply --exclude-schemas "temp_*,cache_*"
pgmt apply --no-comments --no-grants
OptionDefault
databases.shadow.autotrue
directories.schema_dirschema
directories.migrations_dirmigrations
directories.baselines_dirschema_baselines
objects.exclude.schemas["pg_*", "information_schema"]
objects.commentstrue
objects.grantstrue
objects.triggerstrue
objects.extensionstrue
migration.default_modesafe_only
migration.create_baselines_by_defaultfalse
migration.tracking_table.schemapublic
migration.tracking_table.namepgmt_migrations