Skip to content

Commit

Permalink
Check for DATABASE_URL in Heroku release phase command (#1302)
Browse files Browse the repository at this point in the history
* Check for DATABASE_URL in Heroku release phase command

When creating review apps, sometimes the database isn't provisioned until after the first build and release are executed, which causes a release phase command failure. This change adds a guard to the release phase command to prevent that case. It shouldn't impact production at all because the database will always be provisioned.

* Tweak

* Try script

* update

* Remove postdeploy script

There's no visibility into the running of this script in the Heroku dashboard, so it's better to just run it manually if it's something you want.
  • Loading branch information
jonahkagan authored Oct 13, 2021
1 parent ba3bf3c commit 442fec3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
release: alembic upgrade head
release: ./heroku-release-phase.sh
web: gunicorn server.app:app --preload
worker: python -m server.worker.worker
slack_worker: python -m server.activity_log.slack_worker
slack_worker: python -m server.activity_log.slack_worker
3 changes: 0 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@
}
},
"name": "arlo",
"scripts": {
"postdeploy": "heroku pg:backups:restore vx-arlo-staging:: -a $HEROKU_APP_NAME --confirm $HEROKU_APP_NAME"
},
"stack": "heroku-18"
}
8 changes: 8 additions & 0 deletions heroku-release-phase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

echo "Attempting to run migrations"
if [[ $DATABASE_URL ]]; then
alembic upgrade head
else
echo "DATABASE_URL not set, skipping migrations"
fi

0 comments on commit 442fec3

Please sign in to comment.