pgschema picks migration strategies that minimize downtime and blocking when making schema changes to production PostgreSQL databases.
Index Operations
Adding Indexes
When adding new indexes,pgschema automatically uses CREATE INDEX CONCURRENTLY to avoid blocking table writes:
pgschema:wait directive blocks the schema migration execution, polls the database to monitor progress, displays the progress to the user, and automatically continues when the operation completes. It tracks:
- Completion status: Whether the index is valid and ready
- Progress percentage: Based on
pg_stat_progress_create_index
Modifying Indexes
When changing existing indexes,pgschema uses a safe “create new, drop old” pattern:
- No downtime during index creation
- Query performance is maintained throughout the migration
- Rollback is possible until the old index is dropped
Constraint Operations
Supported constraint types:- Check constraints: Data validation rules
- Foreign key constraints: Referential integrity with full options
- NOT NULL constraints: Column nullability (via check constraint pattern)
CHECK Constraints
Constraints are added using PostgreSQL’sNOT VALID pattern:
Foreign Key Constraints
Foreign keys use the sameNOT VALID pattern:
NOT NULL Constraints
AddingNOT NULL constraints uses a three-step process:

