-
Notifications
You must be signed in to change notification settings - Fork 5
/
setupdb.sh
executable file
·34 lines (30 loc) · 1.1 KB
/
setupdb.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
#!/usr/bin/env bash
ENVFILE=${1-.env}
[ -f "$ENVFILE" ] && source "$ENVFILE"
drop()
{
echo [*] dropdb -U $POSTGRES_DATABASE_USER -h $POSTGRES_MASTER_SERVICE_HOST -p $POSTGRES_MASTER_SERVICE_PORT --if-exists $POSTGRES_DATABASE_NAME
dropdb -U $POSTGRES_DATABASE_USER -h $POSTGRES_MASTER_SERVICE_HOST -p $POSTGRES_MASTER_SERVICE_PORT --if-exists $POSTGRES_DATABASE_NAME
}
create()
{
echo [*] createdb -U $POSTGRES_DATABASE_USER -h $POSTGRES_MASTER_SERVICE_HOST -p $POSTGRES_MASTER_SERVICE_PORT $POSTGRES_DATABASE_NAME
createdb -U $POSTGRES_DATABASE_USER -h $POSTGRES_MASTER_SERVICE_HOST -p $POSTGRES_MASTER_SERVICE_PORT $POSTGRES_DATABASE_NAME
POSTGRES_MASTER_SERVICE_HOST=$POSTGRES_MASTER_SERVICE_HOST \
POSTGRES_MASTER_SERVICE_PORT=$POSTGRES_MASTER_SERVICE_PORT \
POSTGRES_DATABASE_USER=$POSTGRES_DATABASE_USER \
POSTGRES_DATABASE_PASSWORD=$POSTGRES_DATABASE_PASSWORD\
POSTGRES_DATABASE_NAME=$POSTGRES_DATABASE_NAME farnsworth create
}
case "$1" in
drop)
drop
;;
create)
create
;;
*)
drop
create
;;
esac