summary refs log tree commit diff
path: root/scripts/synapse_port_db
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-09-02 11:11:11 +0100
committerErik Johnston <erik@matrix.org>2015-09-02 11:11:11 +0100
commita9ad647fb27aaa5085a828157f30627edfbe76aa (patch)
treec0fe6bca10ae261ffe2668d019b029218e9af00e /scripts/synapse_port_db
parentMerge pull request #261 from matrix-org/erikj/scripts_clean (diff)
downloadsynapse-a9ad647fb27aaa5085a828157f30627edfbe76aa.tar.xz
Make port script handle empty sent_transactions table
Diffstat (limited to 'scripts/synapse_port_db')
-rwxr-xr-xscripts/synapse_port_db15
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db
index e7ed4c309b..c02dff5ba4 100755
--- a/scripts/synapse_port_db
+++ b/scripts/synapse_port_db
@@ -412,14 +412,17 @@ class Porter(object):
         self._convert_rows("sent_transactions", headers, rows)
 
         inserted_rows = len(rows)
-        max_inserted_rowid = max(r[0] for r in rows)
+        if inserted_rows:
+            max_inserted_rowid = max(r[0] for r in rows)
 
-        def insert(txn):
-            self.postgres_store.insert_many_txn(
-                txn, "sent_transactions", headers[1:], rows
-            )
+            def insert(txn):
+                self.postgres_store.insert_many_txn(
+                    txn, "sent_transactions", headers[1:], rows
+                )
 
-        yield self.postgres_store.execute(insert)
+            yield self.postgres_store.execute(insert)
+        else:
+            max_inserted_rowid = 0
 
         def get_start_id(txn):
             txn.execute(