This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
chaim 16eeeff7b6 feat(kb): add 'caselaw' (פסיקה) as a fourth kind
Court rulings are a distinct content type — long discussion / reasoning,
no enumerated statutory hierarchy, case identifier instead of statute id —
so they get their own kind alongside law/regulation/circular rather than
being shoehorned into one of the existing three.

Migration 003 alters the CHECK constraints on kb_source.kind and
kb_ingest_job.kind to include 'caselaw'. The chunker uses the
circulars path for caselaw too (paragraph + size split, no statutory
section regex); the case identifier is captured at upload time in
kb_source.identifier.

Updates Literal types in ingest_source, admin_kb upload, and the
kb_public SearchRequest. _KINDS in s3.py grows to four so failed/
processed/inbox listings include caselaw subdirs.

Refs Task Master #18 (espocrm-extensions/KnowledgeBase)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-25 16:57:46 +00:00

36 lines
1.4 KiB
PL/PgSQL

-- Migration 003: add 'caselaw' (פסיקה) as a fourth content kind.
--
-- Task Master #18 (espocrm-extensions/KnowledgeBase). Until now the KB
-- holds laws / regulations / circulars only. Court rulings (פסיקה) are
-- a distinct content type — different structure (no numbered sections,
-- long discussion / reasoning, case identifier instead of statute id) —
-- so we surface it as a separate `kind` rather than abusing one of the
-- existing three.
--
-- The CHECK constraints on kb_source.kind and kb_ingest_job.kind are
-- recreated with the expanded set. `kb_source.kind` rules every search
-- and ask path; `kb_ingest_job.kind` rules the upload form. Both must
-- agree.
--
-- Idempotent — wrapped in a transaction; if the constraint is already
-- in the new shape, the DROP is a no-op (IF EXISTS) and the ADD just
-- re-asserts.
--
-- Run as postgres superuser:
-- docker exec -i <pg-container> psql -U postgres -d insurance_kb \
-- -f /tmp/003_caselaw_kind.sql
BEGIN;
ALTER TABLE kb_source DROP CONSTRAINT IF EXISTS kb_source_kind_check;
ALTER TABLE kb_source
ADD CONSTRAINT kb_source_kind_check
CHECK (kind IN ('law','regulation','circular','caselaw'));
ALTER TABLE kb_ingest_job DROP CONSTRAINT IF EXISTS kb_ingest_job_kind_check;
ALTER TABLE kb_ingest_job
ADD CONSTRAINT kb_ingest_job_kind_check
CHECK (kind IN ('law','regulation','circular','caselaw'));
COMMIT;