This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1+ Update the check_schema_delta script to account for when the schema version has been bumped locally.
Original file line number Diff line number Diff line change @@ -40,10 +40,32 @@ def main(force_colors: bool) -> None:
4040 exec (r , locals )
4141 current_schema_version = locals ["SCHEMA_VERSION" ]
4242
43- click .secho (f"Current schema version: { current_schema_version } " )
44-
4543 diffs : List [git .Diff ] = repo .remote ().refs .develop .commit .diff (None )
4644
45+ # Get the schema version of the local file to check against current schema on develop
46+ with open ("synapse/storage/schema/__init__.py" , "r" ) as file :
47+ local_schema = file .read ()
48+ new_locals : Dict [str , Any ] = {}
49+ exec (local_schema , new_locals )
50+ local_schema_version = new_locals ["SCHEMA_VERSION" ]
51+
52+ if local_schema_version != current_schema_version :
53+ # local schema version must be +/-1 the current schema version on develop
54+ if abs (local_schema_version - current_schema_version ) != 1 :
55+ click .secho (
56+ "The proposed schema version has diverged more than one version from develop, please fix!" ,
57+ fg = "red" ,
58+ bold = True ,
59+ color = force_colors ,
60+ )
61+ click .get_current_context ().exit (1 )
62+
63+ # right, we've changed the schema version within the allowable tolerance so
64+ # let's now use the local version as the canonical version
65+ current_schema_version = local_schema_version
66+
67+ click .secho (f"Current schema version: { current_schema_version } " )
68+
4769 seen_deltas = False
4870 bad_files = []
4971 for diff in diffs :
You can’t perform that action at this time.
0 commit comments