summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-11-19 10:49:40 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2019-11-19 10:49:40 +0000
commit5f4b59d0ce098fe3ddcd969e67ca6b7a53e3d991 (patch)
tree98ac84670bd1865da7ae97cc1cbe3cc0dfd8009a
parentAdd changelog (diff)
downloadsynapse-5f4b59d0ce098fe3ddcd969e67ca6b7a53e3d991.tar.xz
Switch to using a delta file github/anoa/device_sql_v2 anoa/device_sql_v2
-rw-r--r--synapse/storage/data_stores/main/deviceinbox.py9
-rw-r--r--synapse/storage/data_stores/main/schema/delta/56/device_stream_id.sql5
2 files changed, 6 insertions, 8 deletions
diff --git a/synapse/storage/data_stores/main/deviceinbox.py b/synapse/storage/data_stores/main/deviceinbox.py
index 6393c4f6de..f04aad0743 100644
--- a/synapse/storage/data_stores/main/deviceinbox.py
+++ b/synapse/storage/data_stores/main/deviceinbox.py
@@ -358,14 +358,7 @@ class DeviceInboxStore(DeviceInboxWorkerStore, DeviceInboxBackgroundUpdateStore)
     def _add_messages_to_local_device_inbox_txn(
         self, txn, stream_id, messages_by_user_then_device
     ):
-        # Compatible method of performing an upsert
-        sql = """
-            INSERT INTO device_max_stream_id
-            (stream_id) VALUES (?)
-            ON CONFLICT DO UPDATE device_max_stream_id
-            SET stream_id = ?
-            WHERE stream_id < ?
-        """
+        sql = "UPDATE device_max_stream_id" " SET stream_id = ?" " WHERE stream_id < ?"
         txn.execute(sql, (stream_id, stream_id))
 
         local_by_user_then_device = {}
diff --git a/synapse/storage/data_stores/main/schema/delta/56/device_stream_id.sql b/synapse/storage/data_stores/main/schema/delta/56/device_stream_id.sql
new file mode 100644
index 0000000000..ae261a70a2
--- /dev/null
+++ b/synapse/storage/data_stores/main/schema/delta/56/device_stream_id.sql
@@ -0,0 +1,5 @@
+INSERT INTO device_max_stream_id (stream_id)
+SELECT 0
+WHERE NOT EXISTS (
+    SELECT 1 FROM device_max_stream_id
+);
\ No newline at end of file