mirror of
https://github.com/kennethreitz-archive/www.gittip.com.git
synced 2026-06-21 15:50:59 +00:00
90bbdd8588
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.
49 lines
1.1 KiB
Bash
Executable File
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 "=============================================================================="
|