From 57f09e01f528b796d6448446f56ac8079988e6ab Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 2 Dec 2019 18:23:41 +0000 Subject: [PATCH 1/3] Fix error when using synapse_port_db on a vanilla synapse db --- scripts/synapse_port_db | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db index 0d3321682c..f24b8ffe67 100755 --- a/scripts/synapse_port_db +++ b/scripts/synapse_port_db @@ -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) From 8ee62e4b98d71feef72987c94eef1ed097746f34 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 2 Dec 2019 18:43:25 +0000 Subject: [PATCH 2/3] Add changelog --- changelog.d/6449.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6449.bugfix diff --git a/changelog.d/6449.bugfix b/changelog.d/6449.bugfix new file mode 100644 index 0000000000..ced16544c9 --- /dev/null +++ b/changelog.d/6449.bugfix @@ -0,0 +1 @@ +Fix assumed missing state_groups index in synapse_port_db. \ No newline at end of file From 768b84409b6ad516796d6452394ff1fe32b9abb1 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Wed, 4 Dec 2019 10:45:56 +0000 Subject: [PATCH 3/3] Update changelog.d/6449.bugfix Co-Authored-By: Erik Johnston --- changelog.d/6449.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/6449.bugfix b/changelog.d/6449.bugfix index ced16544c9..002f33c450 100644 --- a/changelog.d/6449.bugfix +++ b/changelog.d/6449.bugfix @@ -1 +1 @@ -Fix assumed missing state_groups index in synapse_port_db. \ No newline at end of file +Fix error when using synapse_port_db on a vanilla synapse db.