Sha256: 163a2f086fa533159855825e3fadf4623f8dff79dad3ed50caf2b069135726ed

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

#!/usr/bin/env bash

set -e

echo
echo "Uninstalling Database"
echo "= = ="
echo

default_name=event_source

if [ -z ${DATABASE_USER+x} ]; then
  echo "(DATABASE_USER is not set. Default will be used.)"
  user=$default_name
else
  user=$DATABASE_USER
fi

if [ -z ${DATABASE_NAME+x} ]; then
  echo "(DATABASE_NAME is not set. Default will be used.)"
  database=$default_name
else
  database=$DATABASE_NAME
fi

echo

function delete-user {
  echo "Database user is: $user"

  user_exists=`psql postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='$user'"`

  if [ "$user_exists" = "1" ]; then
    echo "Deleting database user \"$user\"..."
    dropuser $user
  else
    echo "Database user \"$user\" does not exist. Not deleting."
  fi

  echo
}

function delete-database {
  echo "Database name is: $database"

  database_exists=`psql postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$database'"`

  if [ "$database_exists" = "1" ]; then
    echo "Deleting database \"$database\"..."
    dropdb $database
  else
    echo "Database \"$database\" does not exist. Not deleting."
  fi

  echo
}


delete-database
delete-user

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
evt-message_store-postgres-0.1.0.0 database/uninstall.sh
evt-event_source-postgres-0.19.0.3 database/uninstall.sh
evt-event_source-postgres-0.19.0.2 database/uninstall.sh