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

Commit

Permalink
Clarifications & updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Nov 27, 2023
1 parent e567649 commit a714262
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
10 changes: 6 additions & 4 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ process, for example:
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
```
Generally Synapse database schemas are compatible across the following versions.
The left column is the latest Synapse version which can be rolled back to the right
column. E.g. Synapse versions v1.13.0 through v1.44.0 can be rolled back safely to
v1.13.0.
Generally Synapse database schemas are compatible across multiple versions, once
a version of Synapse is deployed you may not be able to rollback automatically.
The following table gives the version ranges and the earliest version they can
be rolled back to. E.g. Synapse versions v1.58.0 through v1.61.1 can be rolled
back safely to v1.57.0, but starting with v1.62.0 it is only safe to rollback to
v1.61.0.
<!-- REPLACE_WITH_SCHEMA_VERSIONS -->
Expand Down
34 changes: 22 additions & 12 deletions scripts-dev/schema_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,40 @@ def calculate_version_chart() -> str:
schema_version = None
schema_compat_version = None

# Map of schema version -> Synapse versions at that schema.
# Map of schema version -> Synapse versions which are at that schema version.
schema_versions = defaultdict(list)
# Map of schema version -> Synapse versions which are compatible with that
# schema version.
schema_compat_versions = defaultdict(list)

# Find ranges of versions which are compatible with a schema version.
#
# There are two modes of operation:
#
# 1. If schema_compat_version is None, then Synapse can only move to a new
# version with schema_version >= its current version.
# 2. If schema_compat_version is *not* None, then Synapse can move to a new
# version with schema version >= schema_compat_version.
# 1. Pre-schema_compat_version (i.e. schema_compat_version of None), then
# Synapse is compatible up/downgrading to a version with
# schema_version >= its current version.
#
# 2. Post-schema_compat_version (i.e. schema_compat_version is *not* None),
# then Synapse is compatible up/downgrading to a version with
# schema version >= schema_compat_version.
#
# This is more generous and avoids versions that cannot be rolled back.
#
# See https://github.com/matrix-org/synapse/pull/9933 which was included in v1.37.0.
for tag in get_tags(repo):
schema_version, schema_compat_version = get_schema_versions(tag)

# If a schema compat version is given, prefer that over the schema version.
schema_versions[schema_compat_version or schema_version].append(tag.name)

# Generate a table of which maps a version to the version it can be rolled back to.
result = "| Synapse version | Backwards compatible version |\n"
result += "|-----------------|------------------------------|\n"
for synapse_versions in schema_versions.values():
result += f"| {synapse_versions[-1]: ^15} | {synapse_versions[0]: ^28} |\n"
schema_versions[schema_version].append(tag.name)
schema_compat_versions[schema_compat_version or schema_version].append(tag.name)

# Generate a table which maps the latest Synapse version compatible with each
# schema version.
result = "| Compatible versions | Earliest version |\n"
result += "|{'-' * (19 + 2)}|{'-' * (18 + 2)|\n"
for schema_version, synapse_versions in schema_compat_versions.items():
result += f"| {synapse_versions[0] + ' - ' + synapse_versions[-1]: ^19} | {schema_versions[schema_version][0]: ^18} |\n"

return result

Expand Down

0 comments on commit a714262

Please sign in to comment.