check if db is available first

This is needed to avoid :boom: when deploying to Heroku.