Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
set -ex
if [ -z "$HEROKU_APP_ID" ] ; then
echo '!!! HEROKU_APP_ID not set'
exit 1
fi
if [ -z "$HEROKU_DB_ADDON_ID" ] ; then
echo "!!! HEROKU_DB_ADDON_ID not set. You can get the Heroku DB addon ID from: $ heroku pg:info -a $HEROKU_APP_ID | grep -i 'add-on'"
exit 1
fi
heroku maintenance:on -a $HEROKU_APP_ID
sleep 10
heroku pg:maintenance:run "$HEROKU_DB_ADDON_ID" -a $HEROKU_APP_ID
sleep 10
# wait for the maintenance to complete
heroku pg:wait -a $HEROKU_APP_ID
sleep 10
heroku maintenance:off -a $HEROKU_APP_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment