Files
zulip/scripts/setup/postgres-create-db
Anders Kaseorg 5290519a62 scripts: Always use ON_ERROR_STOP=1 when running psql.
Also use psql -e (--echo-queries) in scripts that use ‘set -x’, so
errors can be traced to a specific query from the output.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-04-22 14:54:19 -07:00

24 lines
558 B
Bash
Executable File

#!/usr/bin/env bash
set -e
set -x
# Make sure the current working directory is readable
cd /
DATABASE_CREATE="
CREATE USER zulip;
ALTER ROLE zulip SET search_path TO zulip,public;
CREATE DATABASE zulip OWNER=zulip;
\\connect zulip
CREATE SCHEMA zulip AUTHORIZATION zulip;
CREATE EXTENSION tsearch_extras SCHEMA zulip;
CREATE EXTENSION pgroonga;
GRANT USAGE ON SCHEMA pgroonga TO zulip;
"
if [ -f /.dockerenv ]; then
echo "$DATABASE_CREATE" | psql -v ON_ERROR_STOP=1 -e
else
echo "$DATABASE_CREATE" | su postgres -c 'psql -v ON_ERROR_STOP=1 -e'
fi