24 lines
469 B
Bash
Executable File
24 lines
469 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
DB_NAME=${1:-kompanion}
|
|
ROLE=${ROLE:-kompanion}
|
|
PASS=${PASS:-komp}
|
|
|
|
psql -v ON_ERROR_STOP=1 <<SQL
|
|
DROP DATABASE IF EXISTS "$DB_NAME";
|
|
CREATE DATABASE "$DB_NAME" OWNER "$ROLE";
|
|
SQL
|
|
|
|
for f in "$(dirname "$0")"/../init/*.sql; do
|
|
if [[ "$f" == *"001_roles.sql"* ]]; then
|
|
continue
|
|
fi
|
|
echo "Applying $f"
|
|
psql -d "$DB_NAME" -f "$f"
|
|
done
|
|
|
|
for f in `dirname($0)`/*.sql; do
|
|
echo "Applying $f"
|
|
psql -d "$DB_NAME" -f "$f"
|
|
done
|