Switch to using a delta file

This commit is contained in:
Andrew Morgan 2019-11-19 10:49:40 +00:00
parent bc7a623980
commit 5f4b59d0ce
2 changed files with 6 additions and 8 deletions

View file

@ -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 = {}

View file

@ -0,0 +1,5 @@
INSERT INTO device_max_stream_id (stream_id)
SELECT 0
WHERE NOT EXISTS (
SELECT 1 FROM device_max_stream_id
);