Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Handle updating schema version without any deltas. #9033

Merged
merged 3 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9033.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow bumping schema version when using split out state database.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this as misc, rather than bugfix, as this doesn't effect anyone other than synapse devs.

17 changes: 10 additions & 7 deletions synapse/storage/prepare_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")


Expand Down