mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
postgres-create-db: Split into non-pgroonga and pgroonga scripts.
Fixes #12655. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
1418b8b05f
commit
f97bb6b65c
@@ -27,7 +27,8 @@ ENV TSEARCH_EXTRAS_VERSION=0.4
|
|||||||
ENV TSEARCH_EXTRAS_DEB=postgresql-${PG_MAJOR}-tsearch-extras_${TSEARCH_EXTRAS_VERSION}_amd64.deb
|
ENV TSEARCH_EXTRAS_DEB=postgresql-${PG_MAJOR}-tsearch-extras_${TSEARCH_EXTRAS_VERSION}_amd64.deb
|
||||||
COPY --from=0 /${TSEARCH_EXTRAS_DEB} /tmp
|
COPY --from=0 /${TSEARCH_EXTRAS_DEB} /tmp
|
||||||
COPY puppet/zulip/files/postgresql/zulip_english.stop /usr/share/postgresql/$PG_MAJOR/tsearch_data/zulip_english.stop
|
COPY puppet/zulip/files/postgresql/zulip_english.stop /usr/share/postgresql/$PG_MAJOR/tsearch_data/zulip_english.stop
|
||||||
COPY scripts/setup/postgres-create-db /docker-entrypoint-initdb.d/postgres-create-db.sh
|
COPY scripts/setup/create-db.sql /docker-entrypoint-initdb.d/zulip-create-db.sql
|
||||||
|
COPY scripts/setup/create-pgroonga.sql /docker-entrypoint-initdb.d/zulip-create-pgroonga.sql
|
||||||
COPY scripts/setup/pgroonga-debian.asc /tmp
|
COPY scripts/setup/pgroonga-debian.asc /tmp
|
||||||
RUN apt-key add /tmp/pgroonga-debian.asc \
|
RUN apt-key add /tmp/pgroonga-debian.asc \
|
||||||
&& echo "deb http://packages.groonga.org/debian/ stretch main" > /etc/apt/sources.list.d/zulip.list \
|
&& echo "deb http://packages.groonga.org/debian/ stretch main" > /etc/apt/sources.list.d/zulip.list \
|
||||||
|
|||||||
6
scripts/setup/create-db.sql
Normal file
6
scripts/setup/create-db.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
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;
|
||||||
3
scripts/setup/create-pgroonga.sql
Normal file
3
scripts/setup/create-pgroonga.sql
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
\connect zulip
|
||||||
|
CREATE EXTENSION pgroonga;
|
||||||
|
GRANT USAGE ON SCHEMA pgroonga TO zulip;
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -48,7 +48,7 @@ su "$POSTGRES_USER" -c 'psql -v ON_ERROR_STOP=1 -e' <<EOF
|
|||||||
DROP DATABASE IF EXISTS zulip;
|
DROP DATABASE IF EXISTS zulip;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
"$(dirname "$0")/postgres-create-db"
|
su "$POSTGRES_USER" -c 'psql -v ON_ERROR_STOP=1 -e' < "$(dirname "$0")/create-db.sql"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clear memcached to avoid contamination from previous database state
|
# Clear memcached to avoid contamination from previous database state
|
||||||
|
|||||||
Reference in New Issue
Block a user