summary refs log tree commit diff
path: root/synapse/storage/prepare_database.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-01-07 13:04:45 +0000
committerErik Johnston <erik@matrix.org>2021-01-07 13:04:45 +0000
commit82a91208d6a9fd3038e1ec4ddcc62cbe359f2a6b (patch)
tree4bc3e65a85fd5ea886128e0a5a96e0ce8872a8bb /synapse/storage/prepare_database.py
parentMerge remote-tracking branch 'origin/develop' into matrix-org-hotfixes (diff)
parentImprove the performance of calculating ignored users in large rooms (#9024) (diff)
downloadsynapse-82a91208d6a9fd3038e1ec4ddcc62cbe359f2a6b.tar.xz
Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/storage/prepare_database.py')
-rw-r--r--synapse/storage/prepare_database.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/synapse/storage/prepare_database.py b/synapse/storage/prepare_database.py

index f91a2eae7a..01efb2cabb 100644 --- a/synapse/storage/prepare_database.py +++ b/synapse/storage/prepare_database.py
@@ -38,7 +38,7 @@ logger = logging.getLogger(__name__) # XXX: If you're about to bump this to 59 (or higher) please create an update # that drops the unused `cache_invalidation_stream` table, as per #7436! # XXX: Also add an update to drop `account_data_max_stream_id` as per #7656! -SCHEMA_VERSION = 58 +SCHEMA_VERSION = 59 dir_path = os.path.abspath(os.path.dirname(__file__)) @@ -375,7 +375,16 @@ def _upgrade_existing_database( specific_engine_extensions = (".sqlite", ".postgres") for v in range(start_ver, SCHEMA_VERSION + 1): - logger.info("Applying schema deltas for v%d", v) + if not is_worker: + logger.info("Applying schema deltas for v%d", v) + + cur.execute("DELETE FROM schema_version") + cur.execute( + "INSERT INTO schema_version (version, upgraded) VALUES (?,?)", + (v, True), + ) + else: + logger.info("Checking schema deltas for v%d", v) # We need to search both the global and per data store schema # directories for schema updates. @@ -489,12 +498,6 @@ def _upgrade_existing_database( (v, relative_path), ) - cur.execute("DELETE FROM schema_version") - cur.execute( - "INSERT INTO schema_version (version, upgraded) VALUES (?,?)", - (v, True), - ) - logger.info("Schema now up to date")