Files
Cyrene_v2/internal/db/migrations/0021_channel_events.down.sql
T
AskaEth ec3f6e810a feat(events): 渠道事件存储地基(Event/Store + SQLite 实现 + 有界计数聚合 + 保留期 GC + 迁移 0021)
- 新包 internal/runtime/events:Tier/Category/Platform/ChannelType/ActorRole 具名常量 + Event/Filter/Counter + Store 六方法
- 留存口径:T2/T3 逐条落行;T1 只计数;unknown / decode_error / link 三例外逐条落行(链路是否活着是事故定案唯一证据)
- 计数:内存聚合 + 上限 512 的有界缓冲 + 满即整批 upsert,落盘失败回填而不丢;GC:保留期 720h/间隔 1h,≤0 = 关闭
- 迁移 0021_channel_events(两表 + 6 索引,含计数 upsert 唯一键);Event 无 flag/正文/URL 字段(design/26 §4.2 红线)
2026-10-05 13:47:25 +08:00

11 lines
565 B
SQL

-- 0021 的回滚:先删索引、再删表(与 0019 的回滚同一顺序口径)。
-- 两张表都是本迁移新建的,回滚不触碰任何既有表。
DROP INDEX IF EXISTS idx_channel_event_counters_category;
DROP INDEX IF EXISTS idx_channel_event_counters_key;
DROP TABLE IF EXISTS channel_event_counters;
DROP INDEX IF EXISTS idx_channel_events_tier;
DROP INDEX IF EXISTS idx_channel_events_channel_id;
DROP INDEX IF EXISTS idx_channel_events_platform_category;
DROP INDEX IF EXISTS idx_channel_events_created_at;
DROP TABLE IF EXISTS channel_events;