database/install-privileges.sh in message-db-2.1.6 vs database/install-privileges.sh in message-db-3.0.0
- old
+ new
@@ -1,37 +1,41 @@
#!/usr/bin/env bash
set -e
+if [ -z ${DATABASE_NAME+x} ]; then
+ database=message_store
+ echo "(DATABASE_NAME is not set. Using: $database.)"
+else
+ database=$DATABASE_NAME
+fi
+
+function run_psql_file {
+ psql $database -q -v ON_ERROR_STOP=1 -f "$1"
+}
+
function script_dir {
val="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "$val"
}
function grant-privileges {
- if [ -z ${DATABASE_NAME+x} ]; then
- database=message_store
- echo "(DATABASE_NAME is not set. Using: $database.)"
- else
- database=$DATABASE_NAME
- fi
-
base=$(script_dir)
echo "» schema privileges"
- psql $database -q -f $base/privileges/schema.sql
+ run_psql_file $base/privileges/schema.sql
echo "» messages table privileges"
- psql $database -q -f $base/privileges/table.sql
+ run_psql_file $base/privileges/table.sql
echo "» sequence privileges"
- psql $database -q -f $base/privileges/sequence.sql
+ run_psql_file $base/privileges/sequence.sql
echo "» functions privileges"
- psql $database -q -f $base/privileges/functions.sql
+ run_psql_file $base/privileges/functions.sql
echo "» views privileges"
- psql $database -q -f $base/privileges/views.sql
+ run_psql_file $base/privileges/views.sql
}
echo "Granting Privileges"
echo "- - -"
grant-privileges