Files
Khaemhat/docs/adr/0004-micro-orm-interno.md
T
Alby96andClaude Opus 5.5 e746d99dab docs: add specification, design docs, mockups, wiki and deploy files
Prepare everything needed before development starts on Khaemhat, the
ERP + CRM for Italian SMEs:

- docs/SPEC.md: the original project specification, unchanged, plus
  CLAUDE.md with operational rules and amendments (Gitea instead of
  GitHub/GHCR, Docker image as the only deliverable).
- ADR 0001-0011 for the baseline decisions.
- Mockups: 22 high-resolution screens, the full gallery, 88 thumbnails
  cropped from it, mockup.css and an index.
- Technical docs (architecture, data model, modules, API, MCP, deploy,
  security, development process, status with open spec questions).
- Full draft wiki in docs/wiki (already published to the Gitea wiki).
- Icons in assets/ and deploy files for Docker Compose and Unraid,
  pointing to the Gitea package registry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 22:26:58 +01:00

27 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ADR 0004 — Micro-ORM interno e migrazioni in C#
- **Stato:** accettata
- **Data:** 2026-11-10
- **Fonte:** SPEC §5.1–§5.3
## Contesto
Senza ORM esterni (ADR 0002) e con due motori (SQLite e PostgreSQL), l'accesso ai dati deve essere tipizzato,
sicuro contro l'iniezione SQL e prevedibile nelle prestazioni.
## Decisione
- `Khaemhat.Data`: mappe esplicite per entità (`EntityMap<T>`), `QueryBuilder<T>` con traduzione di un sottoinsieme
sicuro di espressioni, `Repository<T,TKey>` con concorrenza ottimistica (`row_version`), `UnitOfWork` con
transazioni esplicite, SQL sempre parametrizzato.
- Un provider per dialetto (`Khaemhat.Data.Sqlite`, `Khaemhat.Data.PostgreSql`): tipi, paginazione, upsert, lock.
- Migrazioni in C# (`[Migration(yyyymmdd_nnn, "name")]`) con DDL generato per dialetto, catalogo di sistema e
aziendale, tabella `schema_version` con checksum, nessun downgrade.
- Decimali `numeric(19,6)` su PostgreSQL e interi scalati ×10⁶ su SQLite.
## Conseguenze
- Nessun codice sopra lo strato dati conosce il motore; i test girano su entrambi.
- Le query pesanti (report, partitari) possono usare SQL scritto a mano per dialetto, sempre parametrizzato.
- `docs/DATA-MODEL.md` si genera dalle mappe (`scripts/gen-datamodel.sh`).