Skip to main content
Rolling back schema changes is inherently risky and may result in data loss. Always test rollback procedures in non-production environments and ensure you have complete database backups before proceeding.
The pgschema approach to rollback is to revert your schema file to a previous version and apply the changes using the standard plan/apply workflow. This ensures rollbacks follow the same safety mechanisms as forward migrations.
1

Revert Schema File

Use git to revert your schema file to the previous working version.
This restores your schema file to the state before the problematic migration was applied.
2

Generate Rollback Plan

Create and review a migration plan that will rollback the database to match the reverted schema file.
The plan will show exactly what changes pgschema will make to rollback the database to the previous schema state.
3

Execute Rollback

Apply the rollback plan with appropriate safety measures for production environments.