From b9210e3ed94d84693d89febce05cb0882bd1fdd8 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 5 Jun 2023 21:14:13 +0000 Subject: [PATCH] upgrade-zulip: Set postgresql.version from running version, not a guess. --- scripts/lib/upgrade-zulip-stage-2 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 793eee2e02..6d6adb6445 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -208,17 +208,18 @@ def shutdown_server() -> None: if os.path.exists("/etc/init.d/postgresql"): postgresql_version = get_config(config_file, "postgresql", "version") if not postgresql_version: - default_postgresql_version = { - ("debian", "11"): "13", - ("debian", "12"): "15", - ("ubuntu", "20.04"): "12", - ("ubuntu", "22.04"): "14", - ("centos", "7"): "11", - } - if (vendor, os_version) in default_postgresql_version: - postgresql_version = default_postgresql_version[(vendor, os_version)] - else: - error_desupported_os(vendor, os_version) + postgresql_version = subprocess.check_output( + # We use the _current_ deploy's manage.py, since ours has not + # yet had its virtualenv configured yet. + [ + "../current/manage.py", + "shell", + "-c", + "from django.db import connection; print(int(connection.cursor().connection.server_version/10000))", + ], + preexec_fn=su_to_zulip, + text=True, + ).strip() subprocess.check_call( [ "crudini",