diff options
author | Erik Johnston <erik@matrix.org> | 2016-08-04 11:35:49 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-08-04 11:38:08 +0100 |
commit | 7c7786d4e1ead0e1ea9bfd20b18bdbdcff806fb5 (patch) | |
tree | 33476fc9e6513bd750ee845830bb20113254d43a /scripts | |
parent | Handle the fact that some tables have negative rowid rows (diff) | |
download | synapse-7c7786d4e1ead0e1ea9bfd20b18bdbdcff806fb5.tar.xz |
Allow upgrading from old port_from_sqlite3 format
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/synapse_port_db | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/synapse_port_db b/scripts/synapse_port_db index 69503cedb6..66c61b0198 100755 --- a/scripts/synapse_port_db +++ b/scripts/synapse_port_db @@ -458,6 +458,27 @@ class Porter(object): ")" ) + # The old port script created a table with just a "rowid" column. + # We want people to be able to rerun this script from an old port + # so that they can pick up any missing events that were not + # ported across. + def alter_table(txn): + txn.execute( + "ALTER TABLE IF EXISTS port_from_sqlite3" + " RENAME rowid TO forward_rowid" + ) + txn.execute( + "ALTER TABLE IF EXISTS port_from_sqlite3" + " ADD backward_rowid bigint NOT NULL DEFAULT 0" + ) + + try: + yield self.postgres_store.runInteraction( + "alter_table", alter_table + ) + except Exception as e: + logger.info("Failed to create port table: %s", e) + try: yield self.postgres_store.runInteraction( "create_port_table", create_port_table |