#!/bin/bash
set -e

POSTGRES="psql --username ${POSTGRES_USER}"

echo "Creating database role: ${POSTGRES_ADMIN_USER}"

$POSTGRES <<-EOSQL
CREATE USER ${POSTGRES_ADMIN_USER} WITH CREATEDB SUPERUSER PASSWORD '${POSTGRES_ADMIN_PASSWORD}';
\c iris_db;
CREATE EXTENSION IF NOT EXISTS pgcrypto CASCADE;
EOSQL