#!/bin/sh

# Run this script to set up a review app's database and worker dyno

set -e

if [ -z "$1" ]; then
  printf "You must provide a review app (same as the pull request) id.\n"
  exit 64
fi

PARENT_APP_NAME=<%= app_name.dasherize %>-staging
APP_NAME=<%= app_name.dasherize %>-staging-pr-$1
URL=`heroku pg:backups public-url -a $PARENT_APP_NAME`

heroku pg:backups restore $URL DATABASE_URL --confirm $APP_NAME --app $APP_NAME
heroku run rake db:migrate --exit-code --app $APP_NAME
heroku ps:scale worker=1 --app $APP_NAME
heroku restart --app $APP_NAME

#!/bin/sh

# Run this script to set up a review app's database and worker dyno

set -e

if [ -z "$1" ]; then
  printf "You must provide a review app (same as the pull request) id.\n"
  exit 64
fi

PARENT_APP_NAME=<%= app_name.dasherize %>-staging
APP_NAME=<%= app_name.dasherize %>-staging-pr-$1
URL=`heroku pg:backups public-url --app $PARENT_APP_NAME`

heroku pg:backups restore $URL DATABASE_URL --confirm $APP_NAME --app $APP_NAME
heroku run rake db:migrate --exit-code --app $APP_NAME
heroku ps:scale worker=1 --app $APP_NAME
heroku restart --app $APP_NAME

Expand `-a` flag in `bin/setup_review_app`
Expand `-a` flag in `bin/setup_review_app`

`-a` is expanded to `--app` in the other occurrences in the file, so let
us expand it for consistency.
