memories table stores persistent AI memory blobs that the chat agent reads before composing a response. Each row holds a single free-text memory string scoped to either a workspace (type = 'workspace') or to a specific workspace member (type = 'user'). The entity is exclusively written by the AI Memory pipeline (MemoryService) via a fire-and-forget Cloud Task dispatcher; no user-facing PATCH route exists. Uniqueness constraints guarantee at most one workspace-scoped memory per workspace and at most one user-scoped memory per membership.
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.
API operations
Data model
Attributes
Relationships
System-computed
- memory_id — generated via gen_random_uuid() on INSERT
- created_at — set by MikroORM onCreate hook at INSERT time, never mutated
- updated_at — set by MikroORM onCreate hook at INSERT; refreshed by onUpdate hook on every subsequent write
- type default — defaults to MemoryType.USER (‘user’) at the entity level; column DEFAULT ‘user’ also enforced in Postgres
- Partial unique indexes —
memories_workspace_unique: at most one row per workspace_pk WHERE type = ‘workspace’;memories_membership_unique: at most one row per membership_pk WHERE type = ‘user’ — enforced by MemoryRepository.upsertForWorkspace / upsertForMembership (find-or-create pattern) - CHECK constraint memories_type_membership_check — ensures type/membership_pk coherence: user rows must have membership_pk NOT NULL; workspace rows must have membership_pk NULL
- Whole-record upsert — MemoryService.upsertMemory() writes the entire memory blob atomically on each LLM extraction cycle; there is no incremental append path
Example
/Users/maximechampoux/platform/apps/api/src/database/entities/Memory.ts · domain: intelligence · tier: Activity