summary refs log tree commit diff
path: root/synapse/storage/schema
diff options
context:
space:
mode:
authorPatrick Cloke <patrickc@matrix.org>2022-07-29 13:57:43 -0400
committerPatrick Cloke <patrickc@matrix.org>2022-11-30 08:20:48 -0500
commitf5ef7e13d7e60bd9b901f90da250c7c6d1ba1f53 (patch)
treeeda24c26e7673db3b2e2d5bda8c45da558bf2325 /synapse/storage/schema
parentCopy PostgresEngine. (diff)
downloadsynapse-f5ef7e13d7e60bd9b901f90da250c7c6d1ba1f53.tar.xz
Initial abstraction.
Diffstat (limited to 'synapse/storage/schema')
-rw-r--r--synapse/storage/schema/main/delta/56/unique_user_filter_index.py3
-rw-r--r--synapse/storage/schema/main/delta/68/05partial_state_rooms_triggers.py9
-rw-r--r--synapse/storage/schema/main/delta/69/01as_txn_seq.py2
3 files changed, 9 insertions, 5 deletions
diff --git a/synapse/storage/schema/main/delta/56/unique_user_filter_index.py b/synapse/storage/schema/main/delta/56/unique_user_filter_index.py
index bb7296852a..9983c77548 100644
--- a/synapse/storage/schema/main/delta/56/unique_user_filter_index.py
+++ b/synapse/storage/schema/main/delta/56/unique_user_filter_index.py
@@ -1,7 +1,6 @@
 import logging
 from io import StringIO
 
-from synapse.storage.engines import PostgresEngine
 from synapse.storage.prepare_database import execute_statements_from_stream
 
 logger = logging.getLogger(__name__)
@@ -21,7 +20,7 @@ def run_upgrade(cur, database_engine, *args, **kwargs):
 
 
 def run_create(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
+    if database_engine.supports_select_distinct_on:
         select_clause = """
             SELECT DISTINCT ON (user_id, filter_id) user_id, filter_id, filter_json
             FROM user_filters
diff --git a/synapse/storage/schema/main/delta/68/05partial_state_rooms_triggers.py b/synapse/storage/schema/main/delta/68/05partial_state_rooms_triggers.py
index a2ec4fc26e..ae6e7137b8 100644
--- a/synapse/storage/schema/main/delta/68/05partial_state_rooms_triggers.py
+++ b/synapse/storage/schema/main/delta/68/05partial_state_rooms_triggers.py
@@ -18,7 +18,12 @@ This migration adds triggers to the partial_state_events tables to enforce uniqu
 
 Triggers cannot be expressed in .sql files, so we have to use a separate file.
 """
-from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine, Sqlite3Engine
+from synapse.storage.engines import (
+    BaseDatabaseEngine,
+    PostgresEngine,
+    PsycopgEngine,
+    Sqlite3Engine,
+)
 from synapse.storage.types import Cursor
 
 
@@ -43,7 +48,7 @@ def run_create(cur: Cursor, database_engine: BaseDatabaseEngine, *args, **kwargs
             END;
             """
         )
-    elif isinstance(database_engine, PostgresEngine):
+    elif isinstance(database_engine, (PostgresEngine, PsycopgEngine)):
         cur.execute(
             """
             CREATE OR REPLACE FUNCTION check_partial_state_events() RETURNS trigger AS $BODY$
diff --git a/synapse/storage/schema/main/delta/69/01as_txn_seq.py b/synapse/storage/schema/main/delta/69/01as_txn_seq.py
index 24bd4b391e..4856569ceb 100644
--- a/synapse/storage/schema/main/delta/69/01as_txn_seq.py
+++ b/synapse/storage/schema/main/delta/69/01as_txn_seq.py
@@ -21,7 +21,7 @@ from synapse.storage.engines import PostgresEngine
 
 
 def run_create(cur, database_engine, *args, **kwargs):
-    if isinstance(database_engine, PostgresEngine):
+    if database_engine.supports_sequences:
         # If we already have some AS TXNs we want to start from the current
         # maximum value. There are two potential places this is stored - the
         # actual TXNs themselves *and* the AS state table. At time of migration