Skip to content

Commit 6c98222

Browse files
authored
fix: check sqlmesh version before sqlglot/schema (#4898)
1 parent 5b9e2f9 commit 6c98222

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

sqlmesh/core/state_sync/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,15 @@ def raise_error(
245245
f"{lib} (local) is using version '{local}' which is behind '{remote}' (remote).{upgrade_suggestion}"
246246
)
247247

248+
if major_minor(SQLMESH_VERSION) != major_minor(versions.sqlmesh_version):
249+
raise_error(
250+
"SQLMesh",
251+
SQLMESH_VERSION,
252+
versions.sqlmesh_version,
253+
remote_package_version=versions.sqlmesh_version,
254+
ahead=major_minor(SQLMESH_VERSION) > major_minor(versions.sqlmesh_version),
255+
)
256+
248257
if SCHEMA_VERSION != versions.schema_version:
249258
raise_error(
250259
"SQLMesh",
@@ -263,15 +272,6 @@ def raise_error(
263272
ahead=major_minor(SQLGLOT_VERSION) > major_minor(versions.sqlglot_version),
264273
)
265274

266-
if major_minor(SQLMESH_VERSION) != major_minor(versions.sqlmesh_version):
267-
raise_error(
268-
"SQLMesh",
269-
SQLMESH_VERSION,
270-
versions.sqlmesh_version,
271-
remote_package_version=versions.sqlmesh_version,
272-
ahead=major_minor(SQLMESH_VERSION) > major_minor(versions.sqlmesh_version),
273-
)
274-
275275
return versions
276276

277277
@abc.abstractmethod

tests/core/state_sync/test_state_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ def test_version_schema(state_sync: EngineAdapterStateSync, tmp_path) -> None:
20912091

20922092
with pytest.raises(
20932093
SQLMeshError,
2094-
match=rf"SQLMesh \(local\) is using version '{SCHEMA_VERSION}' which is ahead of '0'",
2094+
match=rf"SQLMesh \(local\) is using version '{SQLMESH_VERSION}' which is ahead of '0.0.0' \(remote\). Please run a migration \('sqlmesh migrate' command\).",
20952095
):
20962096
state_sync.get_versions()
20972097

0 commit comments

Comments
 (0)