forked from gratipay/gratipay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recreate-schema.sh
executable file
·42 lines (30 loc) · 1.25 KB
/
recreate-schema.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
#!/bin/sh
# Exit if any subcommands or pipeline returns a non-zero status.
set -e
# Make a database for Gittip.
#
# usage: DATABASE_URL=postgres://foo:bar@baz:5234/buz recreate-schema.sh
echo "=============================================================================="
# I got the idea for dropping the schema as a way to clear out the db from
# http://www.postgresql.org/message-id/200408241254.19075.josh@agliodbs.com. On
# Heroku Postgres we don't have permission to drop and create the db as a
# whole.
echo "Recreating public schema ... "
echo "DROP SCHEMA public CASCADE" | psql $DATABASE_URL
echo "CREATE SCHEMA public" | psql $DATABASE_URL
echo "=============================================================================="
echo "Applying schema.sql ..."
echo
psql $DATABASE_URL < enforce-utc.sql
psql $DATABASE_URL < schema.sql
echo "=============================================================================="
echo "Looking for branch.sql ..."
echo
if [ -f branch.sql ]
then psql $DATABASE_URL < branch.sql
else
echo "None found. That's cool. You only need a branch.sql file if you want to include"
echo "schema changes with your pull request."
fi
echo
echo "=============================================================================="