rwadurian/backend/services/presence-service/prisma/migrations
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
..
20241204000000_init fix(db): 添加缺失的数据库迁移文件 2025-12-15 21:53:31 -08:00
20250305000000_add_device_fields_to_event_log feat(telemetry): 设备字段提升为顶层结构化列(Amplitude 风格) 2026-03-05 09:50:48 -08:00
20250306010000_add_device_profile feat(presence): 添加设备档案表,实现事件流水+设备快照分离 2026-03-05 19:31:33 -08:00