The Plan-Review-Apply workflow separates change planning from execution, creating a safety gate that prevents unintended database modifications:Documentation Index
Fetch the complete documentation index at: https://www.pgschema.com/llms.txt
Use this file to discover all available pages before exploring further.
- Plan - Generate a detailed migration plan showing exactly what will change
- Review - Examine the plan for correctness, safety, and business impact
- Apply - Execute the reviewed and approved changes
Workflow
Step 1: Plan Your Changes
Generate a migration plan to see what changes pgschema will make:Step 2: Review the Plan
Examine the generated plan carefully:Step 3: Apply the Changes
Once the plan is approved, apply the changes:Detect Concurrent Changes with Fingerprinting
Fingerprinting ensures that the exact changes you reviewed in the plan are the changes that get applied, maintaining the integrity of the Plan-Review-Apply workflow.
pgschema plan, it captures a snapshot (fingerprint) of the current database schema state.
Later, when you run pgschema apply, it verifies that the database hasn’t changed since the plan was generated. This prevents scenarios where:
- Someone else modified the database between your plan and apply
- The database drifted from the expected state
- Multiple developers are making concurrent schema changes
How Fingerprinting Works
- During Plan: pgschema calculates a fingerprint of the current database schema
-
Plan Storage: The fingerprint is embedded in the plan
- During Apply: pgschema recalculates the database fingerprint and compares it with the stored one
- Safety Check: If fingerprints don’t match, apply is aborted with an error
Fingerprint Validation Example
Online DDL
pgschema automatically generates migration plans that use online DDL strategies to minimize downtime. When possible, operations like index creation, constraint addition, and schema modifications are executed using PostgreSQL’s concurrent and non-blocking features. For detailed information about online DDL patterns and strategies, see the Online DDL documentation.
