#!/usr/bin/env bash
set -e

#prepopulate db with dumps
DUMP_PATH="${BASH_SOURCE%/*}/postgresql-dump/*"
for file in $DUMP_PATH
do
    basename="${file##*/}"
    db="${basename%.*}"
    echo "Importing user/db $basename"
    PGPASSWORD="$MASTER_PASSWORD" psql -p "$PORT" --host "$ENDPOINT_ADDRESS" --username "$db" --dbname "$db" < "$file"
done
