feat(db): V24 — citation treatment column + halacha corroboration link table (X11)
This commit is contained in:
@@ -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 def _run_schema_migrations(pool: asyncpg.Pool) -> None:
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
await conn.execute(SCHEMA_SQL)
|
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_V21_SQL)
|
||||||
await conn.execute(SCHEMA_V22_SQL)
|
await conn.execute(SCHEMA_V22_SQL)
|
||||||
await conn.execute(SCHEMA_V23_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:
|
async def init_schema() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user