timescaledb/scripts/setup-db.sh
Erik Nordström 036c40886c Simplify cluster setup
Setting up single node is now:

```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select setup_single_node();
```

To setup a cluster do (on meta node):
```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select set_meta();
```

on data node:
```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select join_cluster('metadb', 'metahost');
```

This assumes that the commands are issued by the same user on both the
meta node and the data node. Otherwise the data node also has to
specify the user name to use when connecting to the meta node.
2017-02-07 12:22:36 +01:00

23 lines
419 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 iobeamdb CASCADE;
\o /dev/null
\echo 'Set up database...'
select setup_single_node();
\echo 'Success'
EOF