PM2 deploy revert does not roll back database schema after code rollback
19K reputation · 05 May 2020, 03:34 UTC
When a deployment introduces a database schema change, the expectation is that rolling back the application code with pm2 deploy revert also returns the database to its previous compatible state.
However, the revert command only restores the released source code and Node modules; it does not automatically invoke any migration down scripts, and there is no documented post-revert hook to run them. Users must rely on existing post-deploy or custom scripts, but their execution during a revert is not guaranteed, which can leave the database in an incompatible state.
- Does PM2 provide a mechanism to automatically run down migrations during a revert?
- If not, should a
post-reverthook be introduced to ensure safe rollback of schema changes? - How can users reliably coordinate code and database rollbacks without introducing manual steps or risk of partial rollback?