83 lines
1.9 KiB
Markdown
83 lines
1.9 KiB
Markdown
# 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`
|
||
- `market_platforms`
|
||
- `market_campaigns`
|
||
- `market_campaign_snapshots`
|
||
- `market_campaign_products`
|
||
- `market_product_price_history`
|
||
- `market_product_matches`
|
||
- `market_crawler_runs`
|
||
|
||
### 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
|