Created
March 8, 2013 05:56
-
-
Save pix0r/5114492 to your computer and use it in GitHub Desktop.
Heroku PostGIS databases don't seem to be working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
APP=$1 | |
APP_ARG="" | |
if [ "$APP" != "" ]; then | |
APP_ARG=" -a $APP" | |
fi | |
DB_NAME="" | |
function finish { | |
if [ "$DB_NAME" != "" ]; then | |
CONFIRM_ARG="" | |
if [ "$APP" != "" ]; then | |
CONFIRM_ARG=" --confirm $APP" | |
fi | |
heroku addons:remove $DB_NAME $APP_ARG $CONFIRM_ARG | |
fi | |
} | |
trap finish EXIT | |
set -x verbose | |
DB_URL=`heroku addons:add heroku-postgresql:ronin --version=9.1 $APP_ARG | grep Attached | sed -e s/.*HEROKU/HEROKU/` | |
if [ "$DB_URL" == "" ]; then | |
echo "Error creating DB" | |
exit 1 | |
fi | |
DB_NAME=`echo $DB_URL | sed -e s/_URL//` | |
heroku pg:wait $APP_ARG | |
echo "Current PostGIS version (should error)..." | |
echo "select postgis_version();" | heroku pg:psql $DB_NAME $APP_ARG | |
echo "Enabling PostGIS" | |
echo "create extension postgis" | heroku pg:psql $DB_NAME $APP_ARG | |
echo "Now PostGIS version (should work)..." | |
echo "select postgis_version();" | heroku pg:psql $DB_NAME $APP_ARG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment