forked from hngprojects/hng_boilerplate_java_web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-db.sh
executable file
·33 lines (24 loc) · 925 Bytes
/
init-db.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
#!/bin/bash
# set -e
# # Create the admindb database
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
# CREATE DATABASE $POSTGRES_DEV_DB;
# GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DEV_DB TO $POSTGRES_USER;
# EOSQL
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
SELECT 'CREATE DATABASE $POSTGRES_DEV_DB'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$POSTGRES_DEV_DB')\gexec
GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DEV_DB TO $POSTGRES_USER;
EOSQL
# set -e
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "app" <<-EOSQL
# DO \$\$
# BEGIN
# IF NOT EXISTS (SELECT FROM pg_database WHERE datname = 'app') THEN
# PERFORM dblink_exec('dbname=' || current_database(), 'CREATE DATABASE app');
# END IF;
# END
# \$\$;
# EOSQL