transformations.sh 489 Bytes
#!/bin/bash

set -ex

touch /tmp/pgpass
chmod 0600 /tmp/pgpass
echo "*:*:*:*:CHANGEME" > /tmp/pgpass
export PGPASSFILE=/tmp/pgpass

_import() {
	psql -w -h ${POSTGRESQL_HOST} -U postgres "$1"
}

ls -alR /workspace
for file in /workspace/transformations/*; do
	[[ -e $file ]] || continue
	case "$file" in
		(*.sql.gz)
			zcat "$file" | _import postgres
			;;
		(*.sql)
			cat "$file" | _import postgres
			;;
		(*.sh)
			"$file"
			;;
		(*)
			echo "Ignoring file: $file"
			;;
	esac
done