Files
HiveGrid-Wireframes/hivegrid-cloud/prisma/schema/activity.prisma
T

40 lines
1.5 KiB
Plaintext

/// Actor that produced an activity. Small closed set → enum.
enum ActivityActorKind {
user
system
automation
ki_agent
}
/// User-facing business activity timeline (M045 / M01 Block E).
///
/// DISTINCT from the tamper-evident, hash-chained `AuditEvent` (M001): `Activity`
/// is the per-entity, human-readable stream shown to tenant users (calls, notes,
/// emails, status changes, …). Every writing module appends here via
/// `logActivity()` from `@hivegrid/activity` (AGENTS DoD #14).
///
/// `activityType` and `subjectType` are stored as strings (extensible per module —
/// see the `ActivityType` / `ActivitySubjectType` unions in `@hivegrid/activity`),
/// not Prisma enums, to avoid a schema migration for every new module event.
///
/// Tenant isolation: RLS policy is added with M27 (Auth/Tenancy); until then access
/// is App-Level-scoped via the tenant-scoped query helpers.
model Activity {
id String @id @default(cuid())
tenantId String
createdAt DateTime @default(now())
actorUserId String?
actorKind ActivityActorKind
activityType String
subjectType String
subjectId String
relatedEntityRefs Json?
metadata Json?
summaryText String
// Per-entity timeline (default view), tenant-wide stream, and type filter.
@@index([tenantId, subjectType, subjectId, createdAt])
@@index([tenantId, createdAt])
@@index([tenantId, activityType])
}