Question
Can PM2’s Deploy Rollback Safely Revert Database Migrations?
Tasadduq BurneyownerOwner · Founder
25.5K reputation · 17 Dec 2025, 08:15 UTC
135.5K views0
Goal
Deploying a new application version that includes a database schema change requires that the rollback process also revert the migration. PM2’s pm2 deploy command can roll back application code, but it does not touch the database.
Constraints and Uncertainty
- Rollback only reverts the last commit, leaving the database in the new state.
- A mismatch between code and schema can cause runtime errors or data corruption.
- PM2’s documentation offers no built‑in migration rollback support.
Unresolved Decision
Is there a way to extend PM2 or configure it so that a rollback also triggers the appropriate migration rollback, or is manual intervention always required?
Specific Questions
- Which PM2 feature or plugin could coordinate database migration rollbacks with code rollbacks?
- Can a custom post‑rollback hook be used to trigger migration rollback scripts automatically?
- Does PM2 support a mechanism to detect pending migrations and abort a rollback if the database schema diverges from the previous commit?