rwadurian/backend/services/presence-service/prisma
hailin 893513ad78 feat(presence): 添加设备档案表,实现事件流水+设备快照分离
大厂标准架构(Amplitude/Mixpanel):
- analytics_event_log: 事件流水(append-only,每条事件一行)
- analytics_device_profile: 设备快照(每台设备一行,upsert 更新)

设备分布查询从 O(events) 降为 O(devices):
- SELECT COUNT(*), device_brand FROM analytics_device_profile GROUP BY device_brand
  不再需要 COUNT(DISTINCT install_id) 扫描全量事件表

ON CONFLICT (install_id) DO UPDATE:
- COALESCE 保留已有字段(不被 NULL 覆盖)
- last_seen_at 每次上报更新
- event_count 累加(可用于活跃度分析)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 19:31:33 -08:00
..
migrations feat(presence): 添加设备档案表,实现事件流水+设备快照分离 2026-03-05 19:31:33 -08:00
schema.prisma feat(presence): 添加设备档案表,实现事件流水+设备快照分离 2026-03-05 19:31:33 -08:00