summary refs log tree commit diff
path: root/scripts/synapse_port_db
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-04-06 13:48:40 +0100
committerRichard van der Hoff <richard@matrix.org>2018-04-06 15:33:30 +0100
commit6a9777ba028af1d9803d13e879eaf62773c5bd83 (patch)
treed459161d9c38dce48a03302d98de8e5690ffe557 /scripts/synapse_port_db
parentPort script: clean up a bit (diff)
downloadsynapse-6a9777ba028af1d9803d13e879eaf62773c5bd83.tar.xz
Port script: Set up state_group_id_seq
Fixes https://github.com/matrix-org/synapse/issues/3050.
Diffstat (limited to 'scripts/synapse_port_db')
-rwxr-xr-xscripts/synapse_port_db13
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db
index dc1a10bf28..7b23a44854 100755
--- a/scripts/synapse_port_db
+++ b/scripts/synapse_port_db
@@ -550,6 +550,9 @@ class Porter(object):
                 consumeErrors=True,
             )
 
+            # Step 5. Do final post-processing
+            yield self._setup_state_group_id_seq()
+
             self.progress.done()
         except:
             global end_error_exec_info
@@ -709,6 +712,16 @@ class Porter(object):
 
         defer.returnValue((done, remaining + done))
 
+    def _setup_state_group_id_seq(self):
+        def r(txn):
+            txn.execute("SELECT MAX(id) FROM state_groups")
+            next_id = txn.fetchone()[0]+1
+            txn.execute(
+                "ALTER SEQUENCE state_group_id_seq RESTART WITH %s",
+                (next_id,),
+            )
+        return self.postgres_store.runInteraction("setup_state_group_id_seq", r)
+
 
 ##############################################
 ###### The following is simply UI stuff ######