Files
www.gittip.com/makedb.sh
T
Chad Whitacre 90bbdd8588 Move new SQL to branch.sql; #141
Let's try out this pattern: feature branches should collect new SQL
statements in a branch.sql file, and if this exists we'll apply it
during makedb.sh. That should avoid some conflicts when merging from
master out to feature branches, as well as making it clearer that
branch.sql is a work in progress.
2013-04-03 11:54:05 -04:00

49 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -e
# Make a database for Gittip.
#
# usage: makedb.sh {dbname} {owner}
DBNAME_DEFAULT=gittip
DBNAME=${1:-$DBNAME_DEFAULT}
OWNER_DEFAULT=$DBNAME
OWNER=${2:-$OWNER_DEFAULT}
echo "=============================================================================="
printf "Creating user ... "
createuser -s $OWNER && echo "done" || :
echo "=============================================================================="
printf "Dropping db ... "
dropdb $DBNAME && echo "done" || :
echo "=============================================================================="
printf "Creating db ... "
createdb $DBNAME -O $OWNER && echo "done"
echo "=============================================================================="
echo "Applying schema.sql ..."
echo
psql -U $OWNER $DBNAME < enforce-utc.sql
psql -U $OWNER $DBNAME < schema.sql
echo "=============================================================================="
echo "Looking for branch.sql ..."
echo
if [ -f branch.sql ]
then psql -U $OWNER $DBNAME < branch.sql
else echo "None found."
fi
echo
echo "=============================================================================="