-- ============================================================ -- Omika Diagnostic Center — 002_actor_key.sql (Phase 5B2A.1) -- Pseudonymisation ActorKey (HMAC-SHA256) pour la recherche support. -- ============================================================ -- IDEMPOTENT : ADD COLUMN IF NOT EXISTS + CREATE INDEX IF NOT EXISTS. -- AUCUN DROP, AUCUNE suppression, AUCUNE migration destructive. -- PostgreSQL 18 compatible (syntaxe disponible depuis 9.6). -- -- ActorKey = HMAC-SHA256( "v1|tenant:|collaborateur:" ) -- calculé côté SERVEUR (Omika.Api) depuis l'identité AUTHENTIFIÉE (§3). -- Format : hexadécimal minuscule, 64 caractères. NULL = système / sans -- utilisateur / clé HMAC indisponible (fail-open). -- ActorKeyVersion = version de l'algorithme (1 aujourd'hui) → rotation future. -- ============================================================ ALTER TABLE diagnostic_event ADD COLUMN IF NOT EXISTS actor_key TEXT, ADD COLUMN IF NOT EXISTS actor_key_version INTEGER; -- Recherche support « tous les diagnostics d'un collaborateur » (§12) : -- index composé (actor_key, timestamp_utc DESC). CREATE INDEX IF NOT EXISTS ix_diagnostic_event_actor_key_timestamp ON diagnostic_event (actor_key, timestamp_utc DESC);