Log legacy policy constraint drop failures

This commit is contained in:
KaifAhmad1
2026-02-18 00:48:12 +05:30
parent a98f21e5d3
commit 17b0a24257
2 changed files with 27 additions and 2 deletions
+5 -2
View File
@@ -66,8 +66,11 @@ def create_decision_constraints(graph_store: GraphStore) -> None:
try:
# Drop legacy constraint when possible so versioned policies can coexist.
graph_store.execute_query("DROP CONSTRAINT policy_id_unique IF EXISTS")
except Exception:
pass
except Exception as e:
get_logger(__name__).warning(
"Failed to drop legacy policy_id_unique constraint before policy "
f"versioning migration: {e}"
)
try:
graph_store.execute_query(
@@ -0,0 +1,22 @@
"""Regression tests for graph schema migration logging behavior."""
import logging
from unittest.mock import Mock
from semantica.context.graph_schema import create_decision_constraints
def test_create_decision_constraints_logs_legacy_drop_failure(caplog):
graph_store = Mock()
def _execute_query(query, *args, **kwargs):
if "DROP CONSTRAINT policy_id_unique IF EXISTS" in query:
raise RuntimeError("drop failed")
return {"records": []}
graph_store.execute_query = Mock(side_effect=_execute_query)
with caplog.at_level(logging.WARNING):
create_decision_constraints(graph_store)
assert "Failed to drop legacy policy_id_unique constraint" in caplog.text