Files
Khaemhat/docs/adr/0005-database-multipli.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

1.1 KiB

ADR 0005 — SQLite e PostgreSQL, un database per azienda

  • Stato: accettata
  • Data: 2026-11-10
  • Fonte: SPEC §1.3, §1.4, §5.4

Contesto

Le installazioni vanno dalla demo su un portatile all'azienda con centinaia di GB di dati. Più aziende devono poter convivere sulla stessa istanza con amministrazione condivisa ma dati separati.

Decisione

  • SQLite per test, demo, prova e archivi in sola lettura; PostgreSQL ≥ 16 (consigliato 17) per l'uso reale.
  • Un database per azienda: le tabelle operative non hanno company_id. Il database dell'azienda contiene anche i suoi utenti, ruoli, preferenze, metadati degli allegati e audit.
  • Le connection string delle aziende stanno cifrate nel database di sistema (sys_companies, AES-256-GCM con KHAEMHAT_SECRET_KEY); il CompanyRegistry risolve codice → motore e connessione.

Conseguenze

  • Isolamento forte tra aziende; backup, ripristino, clonazione ed eliminazione per azienda.
  • Le query tra aziende diverse non sono possibili per costruzione.
  • Le migrazioni si applicano a ogni database aziendale, all'avvio o da amministrazione.