mirror of https://github.com/zulip/zulip.git
a1151aef8b
During installation on a new host, `create-database` attempts to verify that there isn't a bunch of data already in the database which is it about to drop and recreate. In the most common case, this statement emits a scary-looking warning, since the database does not exist yet: ``` + /home/zulip/deployments/current/scripts/setup/create-database + POSTGRES_USER=postgres ++ crudini --get /etc/zulip/zulip.conf postgresql database_name ++ echo zulip + DATABASE_NAME=zulip ++ crudini --get /etc/zulip/zulip.conf postgresql database_user ++ echo zulip + DATABASE_USER=zulip ++ cd / ++ su postgres -c 'psql -v ON_ERROR_STOP=1 -Atc '\''SELECT COUNT(*) FROM zulip.zerver_message;'\'' zulip' psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: database "zulip" does not exist ``` Because we are attempting to gracefully handle the case where the database does not exist yet, we also continue (and drop the database) in other, less expected cases -- for instance, if database contains a schema we do not expect. Explicitly check for the database existence first, and once we verify that, allow any further failures in the `SELECT COUNT(*)` to abort `create-database`. This serves the dual purpose of hiding the "FATAL" error for the common case when the database does not exist, as well as preventing dropping the database if anything else goes awry. |
||
---|---|---|
.. | ||
apt-repos | ||
__init__.py | ||
compare-settings-to-template | ||
configure-rabbitmq | ||
create-database | ||
create-db.sql | ||
create-pgroonga.sql | ||
flush-memcached | ||
generate-rabbitmq-cookie | ||
generate-self-signed-cert | ||
generate_secrets.py | ||
initialize-database | ||
inline_email_css.py | ||
install | ||
reindex-textual-data | ||
restore-backup | ||
setup-certbot | ||
sha256-tarball-to | ||
terminate-psql-sessions | ||
upgrade-postgresql |