Core Data Model and Migrations
Core Data Model and Migrations
Section titled “Core Data Model and Migrations”This feature is the backbone of the product
Section titled “This feature is the backbone of the product”The legal data model and migration system define the reliability envelope for every present and future feature in Leci. Without schema integrity and predictable migrations, search, revisions, and integrations cannot be trusted.
Implemented scope in current code
Section titled “Implemented scope in current code”The implemented core model includes:
regulation_typesandregulationsfor legal document metadata;document_nodesfor hierarchical legal structure and searchable text;embeddingsfor semantic retrieval preparation;suggestionsandrevisionsfor controlled edits and audit history.
Migration execution behavior
Section titled “Migration execution behavior”Migrations are executed by scripts/migrate.ts, which:
- reads SQL files in
drizzle/; - sorts them by numeric prefix;
- executes each file sequentially;
- logs applied file names.
const migrations = getMigrationFiles();for (const migrationPath of migrations) { const sql = fs.readFileSync(migrationPath, "utf8"); await client.query(sql); process.stdout.write(`Applied ${path.basename(migrationPath)}\n`);}Why this design matters
Section titled “Why this design matters”This design keeps database evolution explicit and reviewable, which is essential in legal-domain systems where accidental data drift can invalidate downstream outputs.
Operational caveats
Section titled “Operational caveats”Planned enhancements
Section titled “Planned enhancements”🚧 Planned Feature — Formal migration governance and rollback policy documentation are roadmap items and not fully codified yet.
🚧 Planned Feature — Automated schema parity checks between Drizzle schema and SQL migration artifacts are planned but not implemented.