Modelo de Dados Core e Migrations
Modelo de Dados Core e Migrations
Seção intitulada “Modelo de Dados Core e Migrations”This feature is the backbone of the product
Seção intitulada “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
Seção intitulada “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
Seção intitulada “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
Seção intitulada “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
Seção intitulada “Operational caveats”Planned enhancements
Seção intitulada “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.