mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
Log legacy policy constraint drop failures
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user