topfans/backend/migrations/2026_06_08_009_statistic_refresh_log.sql
zerosaturation f5ece5e1d2 feat(statistic): T3 service skeleton (config + main + healthz + metrics + 10 SQL)
- 6 config blocks (DB/Redis/Channel/Refresh/Partition/Extension with 4 EnableXxx=false)
- 14 Prometheus metric declarations
- self-impl healthz (/healthz + /metrics) — bypasses pkg/health to keep /metrics
- main.go startup: logger → config → DB → Redis → healthz HTTP :21009
- 10 SQL migrations: events partitioned + 4 MV + 3 pre-agg + refresh_log + 7-day initial

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 17:20:53 +08:00

19 lines
652 B
SQL

-- statistic 服务 refresh_log: 物化视图刷新日志
-- 创建时间: 2026-06-08
-- 关联: spec §3.6
-- 用途: 监控物化视图刷新状态 + 失败告警
CREATE TABLE IF NOT EXISTS statistic.refresh_log (
id BIGSERIAL PRIMARY KEY,
mv_name VARCHAR(128) NOT NULL,
started_at TIMESTAMPTZ NOT NULL,
finished_at TIMESTAMPTZ,
row_count BIGINT,
status VARCHAR(16) NOT NULL, -- 'running' / 'success' / 'failed'
error_message TEXT
);
-- 监控查询主索引
CREATE INDEX IF NOT EXISTS idx_refresh_log_mv_time
ON statistic.refresh_log (mv_name, started_at DESC);