Fix error when using synapse_port_db on a vanilla synapse db

pull/6449/head
Andrew Morgan 2019-12-02 18:23:41 +00:00
parent 72078e4be5
commit 57f09e01f5
1 changed files with 4 additions and 1 deletions

View File

@ -782,7 +782,10 @@ class Porter(object):
def _setup_state_group_id_seq(self):
def r(txn):
txn.execute("SELECT MAX(id) FROM state_groups")
next_id = txn.fetchone()[0] + 1
curr_id = txn.fetchone()[0]
if not curr_id:
return
next_id = curr_id + 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)