補強 5.5 自癒安全回看
All checks were successful
CD Pipeline / deploy (push) Successful in 1m11s

This commit is contained in:
OoO
2026-04-29 22:48:24 +08:00
parent 779b27f676
commit 0875dd8fda
10 changed files with 217 additions and 66 deletions

View File

@@ -16,6 +16,7 @@
| `credentials_passbook.md` | 伺服器、帳密、埠位對照 | 需要維運、部署、憑證核對時 |
| `feedback_db_metadata_import.md` | SQLAlchemy metadata / `create_all()` 漏表鐵律 | 新增 model、修 schema、排查 fresh env 漏表時 |
| `project_phase3f_cleanup_roadmap.md` | ADR-017 執行矩陣與階段紅線 | 正在做 3f 模組化收尾時 |
| `schema_inventory_baseline.md` | DB 表分類與 drift 基線 | 要收斂 migration / ORM / raw SQL 真相時 |
## 關聯 Guide

View File

@@ -0,0 +1,75 @@
# Schema Inventory Baseline
> 目的:提供之後做 DB 收斂、migration 對齊、fresh env 驗證時的最小入口。
## 何時閱讀
- 在修 ORM / migration drift 時
- 在新增資料表或欄位時
- 在排查「哪張表才是真正 source of truth」時
## 目前已確認的三類表
### 1. ORM + metadata 已納管
- `categories`
- `products`
- `price_records`
- `monthly_summary_analysis`
- `users`
- `login_history`
- `permissions`
- `user_permissions`
- `promo_products`
- `trend_records`
- `trend_keywords`
- `trend_analysis`
- `web_search_cache`
- `telegram_users`
- `ai_generation_history`
- `ai_prompt_templates`
- `ai_usage_tracking`
- `ai_insights`
- `agent_context`
- `action_plans`
- `action_outcomes`
- `agent_strategy_weights`
- `incidents`
- `playbooks`
- `heal_logs`
- `import_jobs`
- `import_config`
- `notification_templates`
- `ppt_reports`
- `vendor_stockout`
- `vendor_list`
- `vendor_emails`
- `email_send_log`
- `realtime_sales_monthly`
### 2. SQL migration / raw SQL 仍在用,但未見完整 ORM source of truth
- `ai_price_recommendations`
- `competitor_prices`
- `embedding_retry_queue`
- `backup_log`
### 3. 目前最需要優先對齊的 drift
- `incidents`
ORM`traceback_str`, `matched_playbook_id`
migration 013`error_traceback`, `playbook_id`
- `ai_insights`
migration 010 預設:`avg_quality=0.5`, `status='approved'`
migration 015 預設:`confidence=0.5`, `created_by='system'`
ORM 已在 2026-04-29 P1-1 對齊這組預設
## 下一步建議
1. 為每張 live table 標記:
`ORM-first`
`migration-first`
`legacy/raw-sql`
2. 為 drift 最嚴重的表補正式 migration 修正腳本
3. 建立 fresh env schema smoke test