Skip to content

Commit d44bc6d

Browse files
authored
Fix: don't validate on migration (#771)
1 parent 6fcba94 commit d44bc6d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sqlmesh/core/context.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,7 @@ def scheduler(self, environment: t.Optional[str] = None) -> Scheduler:
311311
@property
312312
def state_sync(self) -> StateSync:
313313
if not self._state_sync:
314-
self._state_sync = self._provided_state_sync or self._scheduler.create_state_sync(self)
315-
if not self._state_sync:
316-
raise ConfigError(
317-
"The operation is not supported when using a read-only state sync"
318-
)
314+
self._state_sync = self._new_state_sync()
319315

320316
if self._state_sync.get_versions(validate=False).schema_version == 0:
321317
self._state_sync.migrate()
@@ -838,7 +834,7 @@ def migrate(self) -> None:
838834
839835
Please contact your SQLMesh administrator before doing this.
840836
"""
841-
self.state_sync.migrate()
837+
self._new_state_sync().migrate()
842838

843839
def print_info(self) -> None:
844840
"""Prints information about connections, models, macros, etc. to the console."""
@@ -942,3 +938,9 @@ def _try_connection(self, connection_name: str, engine_adapter: EngineAdapter) -
942938
)
943939
except Exception as ex:
944940
self.console.log_error(f"Connection '{connection_name}' failed. {ex}")
941+
942+
def _new_state_sync(self) -> StateSync:
943+
state_sync = self._provided_state_sync or self._scheduler.create_state_sync(self)
944+
if not state_sync:
945+
raise ConfigError("The operation is not supported when using a read-only state sync")
946+
return state_sync

0 commit comments

Comments
 (0)