summary refs log tree commit diff
path: root/synapse/storage/databases
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-09-25 09:58:32 +0100
committerGitHub <noreply@github.com>2020-09-25 09:58:32 +0100
commit3e87d79e1c6ef894387ee2f24e008dfb8f5f853f (patch)
tree19ad2f597cdf1d6969bafc2048442b92d0bcc6a1 /synapse/storage/databases
parentMerge branch 'master' into develop (diff)
downloadsynapse-3e87d79e1c6ef894387ee2f24e008dfb8f5f853f.tar.xz
Fix schema delta for servers that have not backfilled (#8396)
Fixes #8395.

Diffstat (limited to 'synapse/storage/databases')
-rw-r--r--synapse/storage/databases/main/schema/delta/58/14events_instance_name.sql.postgres4
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/storage/databases/main/schema/delta/58/14events_instance_name.sql.postgres b/synapse/storage/databases/main/schema/delta/58/14events_instance_name.sql.postgres
index 97c1e6a0c5..c31f9af82a 100644
--- a/synapse/storage/databases/main/schema/delta/58/14events_instance_name.sql.postgres
+++ b/synapse/storage/databases/main/schema/delta/58/14events_instance_name.sql.postgres
@@ -21,6 +21,8 @@ SELECT setval('events_stream_seq', (
 
 CREATE SEQUENCE IF NOT EXISTS events_backfill_stream_seq;
 
+-- If the server has never backfilled a room then doing `-MIN(...)` will give
+-- a negative result, hence why we do `GREATEST(...)`
 SELECT setval('events_backfill_stream_seq', (
-    SELECT COALESCE(-MIN(stream_ordering), 1) FROM events
+    SELECT GREATEST(COALESCE(-MIN(stream_ordering), 1), 1) FROM events
 ));