create-db.sql: Start by dropping the zulip database if needed.

At some point the PostgreSQL Docker image started creating the zulip
database for us, which caused our CREATE DATABASE to fail.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-01-15 19:36:40 -05:00 committed by Tim Abbott
parent 298d45b46a
commit 8c733a3f68
2 changed files with 2 additions and 4 deletions

View File

@ -1,3 +1,5 @@
\connect postgres
DROP DATABASE IF EXISTS zulip;
DO $$BEGIN
CREATE USER zulip;
EXCEPTION WHEN duplicate_object THEN

View File

@ -44,10 +44,6 @@ source "$(dirname "$0")/terminate-psql-sessions" postgres zulip zulip_base
# Make sure the current working directory is readable by postgres
cd /
su "$POSTGRES_USER" -c 'psql -v ON_ERROR_STOP=1 -e' <<EOF
DROP DATABASE IF EXISTS zulip;
EOF
su "$POSTGRES_USER" -c 'psql -v ON_ERROR_STOP=1 -e' < "$(dirname "$0")/create-db.sql"
)