forked from gratipay/gratipay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makedb.sh
executable file
·48 lines (32 loc) · 1.14 KB
/
makedb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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 "=============================================================================="