fix(db): 補建 ai_insights / action_plans 表
這兩張表從未存在於生產 DB,導致: - Code Review 每次 _save_to_db() 靜默失敗 - get_history() 永遠返回空陣列 - /code-review/ 頁面歷史永遠空白 已直接在 production DB 執行 CREATE TABLE; 同步更新 docker/postgres/init/01-init.sql, 確保未來重建 DB 時自動建表。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,33 @@ CREATE TABLE IF NOT EXISTS products (
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- AI Insights — Code Review / Strategy / 洞察結果
|
||||
CREATE TABLE IF NOT EXISTS ai_insights (
|
||||
id SERIAL PRIMARY KEY,
|
||||
insight_type VARCHAR(100) NOT NULL,
|
||||
content TEXT,
|
||||
confidence FLOAT DEFAULT 0.0,
|
||||
created_by VARCHAR(100),
|
||||
status VARCHAR(50) DEFAULT 'active',
|
||||
metadata_json TEXT,
|
||||
period VARCHAR(20),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_insights_type ON ai_insights(insight_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_insights_created ON ai_insights(created_at DESC);
|
||||
|
||||
-- Action Plans — Code Review 修復 / AIOps 派遣
|
||||
CREATE TABLE IF NOT EXISTS action_plans (
|
||||
id SERIAL PRIMARY KEY,
|
||||
action_type VARCHAR(100) NOT NULL,
|
||||
description TEXT,
|
||||
status VARCHAR(50) DEFAULT 'pending',
|
||||
priority INTEGER DEFAULT 3,
|
||||
metadata_json TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_action_plans_type ON action_plans(action_type);
|
||||
|
||||
-- 授權給 momo 用戶
|
||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO momo;
|
||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO momo;
|
||||
|
||||
Reference in New Issue
Block a user