Last Updated: 2022-05-26
I had a deploy script for Heroku:
set -e heroku run rake db:migrate ... # other commands that must ONLY run if the migration was successful
My migrations on Heroku failed, yet the subsequent commands ran. This is because
heroku run rake db:migrate always returns exit code 0 even on error conditions (annoyingly...)
The fix was to scan the output
if heroku run rake db:migrate | grep "rake aborted!"; then exit 1 fi
set -eto halt, ensure that the component commands actually exit non-zero on failure. Refer to docs (and test if non-available).