mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:36:02 -04:00
Sanity-check database before running upgrades (#6982)
Some of the database deltas rely on `config.server_name` being set correctly, so we should check that it is before running the deltas. Fixes #6870.
This commit is contained in:
parent
bbf8886a05
commit
e66f099ca9
3 changed files with 33 additions and 17 deletions
|
@ -278,13 +278,17 @@ def _upgrade_existing_database(
|
|||
the current_version wasn't generated by applying those delta files.
|
||||
database_engine (DatabaseEngine)
|
||||
config (synapse.config.homeserver.HomeServerConfig|None):
|
||||
application config, or None if we are connecting to an existing
|
||||
database which we expect to be configured already
|
||||
None if we are initialising a blank database, otherwise the application
|
||||
config
|
||||
data_stores (list[str]): The names of the data stores to instantiate
|
||||
on the given database.
|
||||
is_empty (bool): Is this a blank database? I.e. do we need to run the
|
||||
upgrade portions of the delta scripts.
|
||||
"""
|
||||
if is_empty:
|
||||
assert not applied_delta_files
|
||||
else:
|
||||
assert config
|
||||
|
||||
if current_version > SCHEMA_VERSION:
|
||||
raise ValueError(
|
||||
|
@ -292,6 +296,13 @@ def _upgrade_existing_database(
|
|||
+ "new for the server to understand"
|
||||
)
|
||||
|
||||
# some of the deltas assume that config.server_name is set correctly, so now
|
||||
# is a good time to run the sanity check.
|
||||
if not is_empty and "main" in data_stores:
|
||||
from synapse.storage.data_stores.main import check_database_before_upgrade
|
||||
|
||||
check_database_before_upgrade(cur, database_engine, config)
|
||||
|
||||
start_ver = current_version
|
||||
if not upgraded:
|
||||
start_ver += 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue