1.6 KiB
1.6 KiB
T701 — mongo product match indexes
Status:
done
Milestone:M0· Phase A
Kind:feat· Est. change:~120 lines
Goal
新增產品型 watch 與 ProductMatch 查詢索引,同時保留既有 Opportunity 唯一鍵與舊資料可讀性。
Depends on
- T700
Inputs
../spec.md§6、§8apps/backend/generate/database/mongo/000014_demand_radar_indexes.*.json- 代表性 nested ProductMatch 查詢與排序條件
Outputs
| 路徑 | 動作 | 說明 |
|---|---|---|
apps/backend/generate/database/mongo/000015_brand_product_radar_indexes.up.json |
add | watch context、產品查詢與 primary 排序索引 |
apps/backend/generate/database/mongo/000015_brand_product_radar_indexes.down.json |
add | 只移除本 migration 新增索引 |
apps/backend/internal/module/radar/repository/**_test.go |
edit/add | 舊唯一鍵與查詢 shape 測試 |
Behavior
(owner_uid, external_id)唯一索引不可改成含 product_id。- 索引不得依賴所有舊文件都有新欄位。
- 避免無效 compound multikey 設計;以代表性 explain 確認 product filter 可用索引。
Out of scope
- 資料批次回填或刪除舊索引
- repository merge 實作(T732)
Acceptance
- migration JSON 可解析,且只新增本 migration 的索引。
- 既有 owner/external 唯一鍵未被 product_id 改寫。
cd apps/backend && go test ./internal/module/radar/repository/... -count=1
Implementation result (2026-08-10): added the 000015 watch/opportunity ProductMatch query indexes and a migration-shape regression test; the repository package passes.