#!/bin/bash

# Copyright 2018-2019 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

# This script drop role and database
#
# It must be given a DB URI or be executed as user postgres with URI postgresql:///postgres.

set -e
export PGOPTIONS='--client-min-messages=warning'

db_uri=$1
db_name=$2
psql="psql $db_uri -v ON_ERROR_STOP="


$psql <<EOF

DROP DATABASE IF EXISTS "$db_name";
DROP ROLE IF EXISTS "$db_name";

EOF
