timescaledb/scripts/setup-db.sh
Rob Kiefer cb90eef350 Rename setup_db() and fix port for local connections
If a user attempts to setup a database while not connecting using
the network, port is NULL and thus fails constraint checks. Instead,
we now use the default Postgres port of 5432 when this happens.

Also, setup_db() is renamed to setup_timescaledb() for clarity in
the presence of other extensions.
2017-03-22 09:26:03 -04:00

23 lines
422 B
Bash
Executable File

#!/bin/bash
set -e
if [[ -z "$DB_NAME" ]]; then
echo "The DB_NAME must be set"
exit 1
fi
# Create data directories for tablespaces tests
psql -h localhost -U postgres -v ON_ERROR_STOP=1 << EOF
\echo 'Creating database: ${DB_NAME}'
CREATE DATABASE ${DB_NAME};
\c ${DB_NAME}
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
\o /dev/null
\echo 'Set up database...'
select setup_timescaledb();
\echo 'Success'
EOF