Skip to content

Commit 17180d7

Browse files
committed
Warn instead of raising or overwriting state
1 parent 2d05722 commit 17180d7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sqlmesh/migrations/v0087_normalize_blueprint_variables.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from dataclasses import dataclass
1818

1919
from sqlglot import exp
20+
from sqlmesh.core.console import get_console
2021
from sqlmesh.utils.migration import index_text_type, blob_text_type
2122

2223

@@ -81,14 +82,15 @@ def migrate(state_sync, **kwargs): # type: ignore
8182
for var, value in dict(blueprint_vars).items():
8283
lowercase_var = var.lower()
8384
if var != lowercase_var:
84-
# Ensures that we crash instead of overwriting snapshot payloads incorrectly
85-
assert lowercase_var not in blueprint_vars, (
86-
"SQLMesh could not migrate the state database successfully, because it detected "
87-
f"two different blueprint variable names ('{var}' and '{lowercase_var}') that resolve "
88-
f"to the same name ('{lowercase_var}') for model '{node['name']}'. Downgrade the local "
89-
"SQLMesh version to the previously-installed one, rename either of these variables, "
90-
"apply the corresponding plan and try again."
91-
)
85+
if lowercase_var in blueprint_vars:
86+
get_console().log_warning(
87+
"SQLMesh is unable to fully migrate the state database, because the "
88+
f"model '{node['name']}' contains two blueprint variables ('{var}' and "
89+
f"'{lowercase_var}') that resolve to the same value ('{lowercase_var}'). "
90+
"This may result in unexpected changes being reported by the next "
91+
"`sqlmesh plan` command. If this happens, consider renaming either variable, "
92+
"so that they won't resolve to their names won't clash when lowercased."
93+
)
9294

9395
del blueprint_vars[var]
9496
blueprint_vars[lowercase_var] = value

0 commit comments

Comments
 (0)