From ca31932a5f3b2a9b8e2d56eaea49eacb05db11d4 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sun, 31 May 2026 18:52:16 +0000 Subject: [PATCH] =?UTF-8?q?feat(db):=20V24=20=E2=80=94=20citation=20treatm?= =?UTF-8?q?ent=20column=20+=20halacha=20corroboration=20link=20table=20(X1?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mcp-server/src/legal_mcp/services/db.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mcp-server/src/legal_mcp/services/db.py b/mcp-server/src/legal_mcp/services/db.py index ea79715..b2222a3 100644 --- a/mcp-server/src/legal_mcp/services/db.py +++ b/mcp-server/src/legal_mcp/services/db.py @@ -1129,6 +1129,27 @@ ALTER TABLE case_law ADD COLUMN IF NOT EXISTS indexed_hash text; """ +SCHEMA_V24_SQL = """ +-- X11: citation corroboration (treatment + halacha-level link) +ALTER TABLE precedent_internal_citations + ADD COLUMN IF NOT EXISTS treatment TEXT DEFAULT ''; + +CREATE TABLE IF NOT EXISTS halacha_citation_corroboration ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + halacha_id UUID NOT NULL REFERENCES halachot(id) ON DELETE CASCADE, + citing_case_law_id UUID REFERENCES case_law(id) ON DELETE CASCADE, + citing_decision_id UUID REFERENCES decisions(id) ON DELETE SET NULL, + source_citation_id UUID NOT NULL, + treatment TEXT NOT NULL, + match_score NUMERIC(4,3) DEFAULT 0, + match_context TEXT DEFAULT '', + created_at TIMESTAMPTZ DEFAULT now(), + UNIQUE (halacha_id, source_citation_id) +); +CREATE INDEX IF NOT EXISTS idx_hcc_halacha ON halacha_citation_corroboration(halacha_id); +""" + + async def _run_schema_migrations(pool: asyncpg.Pool) -> None: async with pool.acquire() as conn: await conn.execute(SCHEMA_SQL) @@ -1155,7 +1176,8 @@ async def _run_schema_migrations(pool: asyncpg.Pool) -> None: await conn.execute(SCHEMA_V21_SQL) await conn.execute(SCHEMA_V22_SQL) await conn.execute(SCHEMA_V23_SQL) - logger.info("Database schema initialized (v1-v23)") + await conn.execute(SCHEMA_V24_SQL) + logger.info("Database schema initialized (v1-v24)") async def init_schema() -> None: