From 2d23250da719e5b81e5793e525171469958466f7 Mon Sep 17 00:00:00 2001
From: Patrick Cloke <clokep@users.noreply.github.com>
Date: Thu, 19 Dec 2024 12:02:47 -0500
Subject: [PATCH] Remove support for PostgreSQL 11 and 12 (#18034)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is essentially matrix-org/synapse#14392. I didn't see anything in
there about updating sytest or complement.

The main driver of this is so that I can use `jsonb_path_exists` in
#17488. 😄
---
 .ci/scripts/calculate_jobs.py       | 2 +-
 .github/workflows/tests.yml         | 2 +-
 changelog.d/18034.removal           | 1 +
 docs/upgrade.md                     | 8 ++++++++
 synapse/storage/engines/postgres.py | 4 ++--
 5 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 changelog.d/18034.removal

diff --git a/.ci/scripts/calculate_jobs.py b/.ci/scripts/calculate_jobs.py
index ea278173db..5249acdc5d 100755
--- a/.ci/scripts/calculate_jobs.py
+++ b/.ci/scripts/calculate_jobs.py
@@ -60,7 +60,7 @@ trial_postgres_tests = [
     {
         "python-version": "3.9",
         "database": "postgres",
-        "postgres-version": "11",
+        "postgres-version": "13",
         "extras": "all",
     }
 ]
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index d91f9c2918..084b08b249 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -581,7 +581,7 @@ jobs:
       matrix:
         include:
           - python-version: "3.9"
-            postgres-version: "11"
+            postgres-version: "13"
 
           - python-version: "3.13"
             postgres-version: "17"
diff --git a/changelog.d/18034.removal b/changelog.d/18034.removal
new file mode 100644
index 0000000000..303b442fd4
--- /dev/null
+++ b/changelog.d/18034.removal
@@ -0,0 +1 @@
+Remove support for PostgreSQL 11 and 12. Contributed by @clokep.
diff --git a/docs/upgrade.md b/docs/upgrade.md
index 45e63b0c5d..6c96cb91a3 100644
--- a/docs/upgrade.md
+++ b/docs/upgrade.md
@@ -117,6 +117,14 @@ each upgrade are complete before moving on to the next upgrade, to avoid
 stacking them up. You can monitor the currently running background updates with
 [the Admin API](usage/administration/admin_api/background_updates.html#status).
 
+# Upgrading to v1.122.0
+
+## Dropping support for PostgreSQL 11 and 12
+
+In line with our [deprecation policy](deprecation_policy.md), we've dropped
+support for PostgreSQL 11 and 12, as they are no longer supported upstream.
+This release of Synapse requires PostgreSQL 13+.
+
 # Upgrading to v1.120.0
 
 ## Removal of experimental MSC3886 feature
diff --git a/synapse/storage/engines/postgres.py b/synapse/storage/engines/postgres.py
index 8c8c6d0414..e4cd359201 100644
--- a/synapse/storage/engines/postgres.py
+++ b/synapse/storage/engines/postgres.py
@@ -99,8 +99,8 @@ class PostgresEngine(
         allow_unsafe_locale = self.config.get("allow_unsafe_locale", False)
 
         # Are we on a supported PostgreSQL version?
-        if not allow_outdated_version and self._version < 110000:
-            raise RuntimeError("Synapse requires PostgreSQL 11 or above.")
+        if not allow_outdated_version and self._version < 130000:
+            raise RuntimeError("Synapse requires PostgreSQL 13 or above.")
 
         with db_conn.cursor() as txn:
             txn.execute("SHOW SERVER_ENCODING")
-- 
GitLab