Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.19.0
Schema Consolidation — Issues Found (2026-03-27)
Status: BLOCKED — needs fixes before re-run
Backup: backups/v3_pre_consolidation_20260327_1643.db (85MB)
DB restored to pre-consolidation state. All other session work intact.
Blocker 1: PK Conflicts on RU Mirror Tables
RU tables use the SAME primary keys as EN tables (they're translations, not new data):
a2_имена_аллаха: allah_id 1-99 = same asnames_of_allahallah_id 1-99a4_производные: deriv_id = same asa4_derivativesderiv_ida5_перекрёстные_ссылки: xref_id = same asa5_cross_refsxref_id
Fix options:
- UPDATE existing rows — add RU content to the EN row (e.g., add
ru_meaningcolumn tonames_of_allah). Preserves PK. - Offset PKs — insert RU rows with PK + 100000 offset. Avoids conflict but breaks ID meaning.
- Separate lang column — generate NEW integer PKs for RU rows, add
lang='RU'column. Original RU PK stored inorig_ru_idcolumn.
Recommended: Option 1 for Names of Allah (same 99 names, just add RU fields). Option 3 for derivatives/cross-refs (genuinely different data rows).
Blocker 2: Orphaned Views
Several views reference tables that don't exist or have been renamed:
m1_phonetic_shifts→ referencesphonetic_shifts(doesn't exist — data is inshift_lookup)a3_quran_refs→ is a VIEW, not a tablea6_country_names→ is a VIEW, not a tablea1_записи→ is a VIEW (data already inentries)a1_entries→ is a VIEW
Fix: Drop orphaned views BEFORE dropping triggers. Current script drops triggers first, which causes ALTER TABLE to fail when it touches a table referenced by a view.
Correct order:
- Save all triggers + views (SQL)
- Drop ALL views
- Drop ALL triggers
- Run migration
- Recreate views (new definitions)
- Recreate triggers (only for surviving tables)
Blocker 3: UNIQUE Constraints from Hardening
harden_v4_schema.py added UNIQUE indexes:
uq_entries_en_rootonentries(en_term, root_id)uq_bitig_orig2onbitig_a1_entries(orig2_term, root_letters)uq_eu_lang_termoneuropean_a1_entries(lang, term)uq_lat_termonlatin_a1_entries(lat_term)uq_roots_lettersonroots(root_letters)
These may block RU data insertion if values collide. Need to check each before INSERT.
Migration Script
consolidate_v5_clean.py — handles Phases 1-3 but needs the above fixes.
consolidate_schema_v5.py — original version, same issues.
What Was Completed This Session
- Domain-specific QUF (12 lattice layers) — 97% pass, 102K rows, 27 tables
- Extended QUF to 130 remaining tables — 40% pass
- 4 new AMR AI modules (jism, hisab, tarikh, istakhbarat) — all with domain QUF colours
- Schema hardening (indexes, views, health check)
- amr_lawh.py QUF filtering wired
- Automated backup script created
- Banned term "theological" removed from all code
- 12-layer lattice architecture defined (replaces 8 academic categories)
Next Session: Consolidation
- Fix Blocker 1: per-table PK strategy (UPDATE for names, new PKs for derivatives)
- Fix Blocker 2: drop views BEFORE triggers
- Fix Blocker 3: handle UNIQUE constraints
- Re-run consolidation
- Update code references (amr_jism.py, uslap_quf.py, uslap_handler.py, etc.)
- Re-run domain QUF on consolidated structure