Sha256: e87272084be3e2fd927964db8c421d81f1bb9fd1fbd7b435b88167aabf7d4623

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

#!/usr/bin/env bash

set -e

echo
echo "Printing Messages"
echo "= = ="
echo

default_name=message_store

if [ -z ${DATABASE_USER+x} ]; then
  echo "(DATABASE_USER is not set)"
  user=$default_name
else
  user=$DATABASE_USER
fi
echo "Database user is: $user"

if [ -z ${DATABASE_NAME+x} ]; then
  echo "(DATABASE_NAME is not set)"
  database=$default_name
else
  database=$DATABASE_NAME
fi
echo "Database name is: $database"

default_table_name=messages

if [ -z ${STREAM_NAME+x} ]; then
  echo "(STREAM_NAME is not set)"
  stream_name=''
else
  stream_name=$STREAM_NAME
  echo "Stream name is: $STREAM_NAME"
fi

echo

if [ -z $stream_name ]; then
  psql $database -U $user -x -P pager=off -c "SELECT * FROM messages ORDER BY global_position ASC"
else
  psql $database -U $user -x -P pager=off -c "SELECT * FROM messages WHERE stream_name = '$stream_name' ORDER BY global_position ASC"
fi

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message-db-2.1.6 database/print-messages.sh
message-db-2.1.5 database/print-messages.sh