diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 91903e6bd8..2b0407c902 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -139,6 +139,7 @@ if os.path.exists("/etc/init.d/postgresql"): if glob.glob("/usr/share/postgresql/*/extension/tsearch_extras.control"): # Remove legacy tsearch_extras package references run_psql_as_postgres( + config_file=config_file, sql_query="DROP EXTENSION IF EXISTS tsearch_extras;", ) subprocess.check_call(["apt-get", "remove", "-y", "postgresql-*-tsearch-extras"]) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 9cb75886b4..350e73bfe5 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -581,8 +581,10 @@ def get_deploy_options(config_file: configparser.RawConfigParser) -> List[str]: def run_psql_as_postgres( + config_file: configparser.RawConfigParser, sql_query: str, ) -> None: + dbname = get_config(config_file, "postgresql", "database_name", "zulip") subcmd = " ".join( map( shlex.quote, @@ -590,8 +592,8 @@ def run_psql_as_postgres( "psql", "-v", "ON_ERROR_STOP=1", - # TODO: Stop hardcoding the database name. - "zulip", + "-d", + dbname, "-c", sql_query, ],