# 單一影片檔案的資料影響範圍 > 每支影片進入 momentry 系統後,其資料散佈在多個位置。 > 上架(install)與下架(uninstall)都必須處理所有位置。 ## 資料位置總覽 | # | 位置 | 類型 | 路徑/表名 | 識別欄位 | 下架方式 | |---|---|---|---|---|---| | 1 | 原始影片檔 | 檔案 | `~/momentry/var/sftpgo/data/demo/{filename}.mp4` | 檔名 | `rm -f` | | 2 | Deep scan 輸出 JSON | 檔案 | `~/momentry/output/{file_uuid}.*.json` | file_uuid | `rm -f {uuid}.*` | | 3 | Workspace SQLite | 檔案 | `~/momentry/output/{file_uuid}.workspace.sqlite` | file_uuid | `rm -f` | | 4 | **videos** 表 | PostgreSQL | `public.videos` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 5 | **processor_results** 表 | PostgreSQL | `public.processor_results` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 6 | **monitor_jobs** 表 | PostgreSQL | `public.monitor_jobs` | `video_id` (非 file_uuid!) | `DELETE WHERE video_id IN (SELECT id FROM videos WHERE file_uuid IN (...))` | | 7 | **scenes** 表 | PostgreSQL | `public.scenes` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 8 | **chunk** 表 | PostgreSQL | `public.chunk` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 9 | **speaker_detections** 表 | PostgreSQL | `public.speaker_detections` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 10 | **trace_profiles** 表 | PostgreSQL | `public.trace_profiles` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 11 | **trace_operation_history** 表 | PostgreSQL | `public.trace_operation_history` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 12 | **tkg_nodes** 表 | PostgreSQL | `public.tkg_nodes` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 13 | **tkg_edges** 表 | PostgreSQL | `public.tkg_edges` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 14 | **tkg_operation_log** 表 | PostgreSQL | `public.tkg_operation_log` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 15 | **pipeline_progress** 表 | PostgreSQL | `public.pipeline_progress` | `file_uuid` | `DELETE WHERE file_uuid IN (...)` | | 16 | Qdrant vectors | Vector DB | collections (e.g. `public_face_embeddings`) | payload.file_uuid | 需 Qdrant API 刪除 (本 sample 無臉部資料) | | 17 | Redis cache | Redis | keys 可能含 file_uuid | key pattern | `FLUSHALL` 或 `DEL pattern*` | | 18 | Proxy SQLite | SQLite | `~/data/users/{user}.sqlite` | 內部記錄 | 清除搜尋歷史時一併清除 | | 19 | system_logs 表 | PostgreSQL | `public.system_logs` | `resource_id` 可能含 uuid | `TRUNCATE` | | 20 | command_execution_log 表 | PostgreSQL | `public.command_execution_log` | `job_id` / `resource_id` | `TRUNCATE` | ## 下架順序(重要) 因為有 FK 關聯,下架必須**先刪子表、再刪主表**: ``` monitor_jobs ← 必須在 videos 之前刪(用 video_id JOIN videos) processor_results ← file_uuid 直接刪 scenes ← file_uuid 直接刪 chunk ← file_uuid 直接刪 speaker_detections ← file_uuid 直接刪 trace_profiles ← file_uuid 直接刪 trace_operation_history ← file_uuid 直接刪 tkg_nodes ← file_uuid 直接刪 tkg_edges ← file_uuid 直接刪 tkg_operation_log ← file_uuid 直接刪 pipeline_progress ← file_uuid 直接刪 videos ← 最後刪(其他表可能 FK 參考它) ``` ## 特殊注意事項 ### monitor_jobs - **舊版 schema(備份來源)沒有 `file_uuid` 欄位**,所以 COPY 到新版 DB 後 `file_uuid` 為 NULL - 必須用 `video_id` JOIN `videos.id` 來篩選,且必須在 `videos` 刪除之前執行 - 新版 schema 有 `file_uuid` 欄位,但來源資料無法填充 ### Qdrant - 本 sample 的 100 支影片 **face_detections = 0**(原始備份就是 dev 測試資料集中在單一 uuid) - 所以 Qdrant 不需要處理(無對應向量資料) - 若未來 sample 包含臉部資料,需加 Qdrant snapshot 或 API 刪除 ### Redis / SQLite - Redis: 可能有快取,但 `FLUSHALL` 已在 clean-install 處理 - SQLite: 搜尋歷史存在 proxy 的 `demo.sqlite`,下架 sample 時不需特別處理(除非要精確刪除單一影片的書籤/標記) ## 上架/下架檢查清單 ### 上架 (install_sample.sh) - [ ] 複製 mp4 到 sftpgo data dir - [ ] 複製 output JSON 到 output dir - [ ] 匯入 DB 資料(COPY) - [ ] 校正 id sequences - [ ] 重啟 momentry server(可選,刷新快取) ### 下架 (uninstall_sample.sh) - [ ] 刪除 DB 資料(單一 session,先子表後主表) - [ ] 刪除 output JSON(`{uuid}.*`) - [ ] 刪除 mp4 檔(檔名對應) - [ ] 可選:清除 Redis 相關 key - [ ] 可選:清除 proxy SQLite 中該影片的書籤/標記 ## 數量對照(100 支 sample) | 表 | 筆數 | 備註 | |---|---|---| | videos | 100 | 每檔 1 筆 | | processor_results | 899 | ~9 processors × 100 files(部分 processor 未執行)| | monitor_jobs | 100 | 每檔 1 筆 | | scenes | 214 | 場景切割結果 | | chunk | 87 | 文字/語音 chunks | | speaker_detections | 263 | 說話者偵測 | | trace_profiles | 206 | VLM 追蹤描述 | | trace_operation_history | 64 | 追蹤操作歷史 | | tkg_nodes | 598 | 時間知識圖節點 | | tkg_edges | 9 | 時間知識圖邊 | | tkg_operation_log | 0 | 無操作記錄 | | pipeline_progress | 0 | 無進度記錄 |