~joetalbott/+junk/ci-dashboard

« back to all changes in this revision

Viewing changes to scripts/create-dev-db

  • Committer: Joe Talbott
  • Date: 2014-09-17 01:34:27 UTC
  • Revision ID: joe.talbott@canonical.com-20140917013427-n1nc2pnvhdz4bfxc
temp commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
PG_PASS=qa_pass
6
6
PG_ADMIN_USER=ciadmin
7
7
PG_ADMIN_PASS=ciadmin
 
8
 
 
9
if [ -f "$DB_DUMPFILE" ]; then
 
10
        echo "Initializing DB from dump-file: $DB_DUMPFILE"
 
11
        juju scp "$DB_DUMPFILE" "$PG_UNIT":
 
12
        juju run --unit "$PG_UNIT" sudo su - postgres<<< "psql < ~/$DB_DUMPFILE"
 
13
fi
 
14
 
8
15
echo "Creating ROLEs and DB at $PG_UNIT ..."
9
16
juju set ${PG_UNIT%/*} admin_addresses="$(${0%/*}/get-ip $APP_UNIT)"
10
17
juju ssh $PG_UNIT sudo su - postgres<<< "psql -c \"CREATE ROLE $PG_ADMIN_USER WITH LOGIN SUPERUSER PASSWORD '$PG_ADMIN_PASS'\"; exit"
11
18
juju ssh $PG_UNIT sudo su - postgres<<< "psql -c \"CREATE ROLE $PG_USER WITH LOGIN PASSWORD '$PG_PASS'\"; exit"
12
 
juju ssh $PG_UNIT sudo su - postgres<<< "psql -c \"CREATE DATABASE qa_dashboard\"; exit"
 
19
 
 
20
if [ ! -f "$DB_DUMPFILE" ]; then
 
21
        juju ssh $PG_UNIT sudo su - postgres<<< "psql -c \"CREATE DATABASE qa_dashboard\"; exit"
 
22
fi
13
23
echo "Setting db_host on $APP_UNIT to $PG_UNIT..."
14
24
juju set ${APP_UNIT%/*} db_host="$(${0%/*}/get-ip $PG_UNIT)"
15
25
sleep 2
16
26
echo "Running initial migration to set up db..."
17
27
juju run --unit $APP_UNIT "actions/migrate $PG_ADMIN_USER $PG_ADMIN_PASS"
 
28