fix(migration): deep fix for B-4 multi-statement and path issues
**問題** (M4 報告): - 1. 多陳述句無法執行 (sqlx::query 限制) - 2. 相對路徑 migrations/ (依賴 CWD) - 3. Worker 路徑缺失 - 4. 欄位缺失 (face_settings, asr_status, completed_at) **修復**: - 使用 sqlx::raw_sql() 支持多陳述句 - 路徑改用 current_exe() 推導 - Worker 啟動時也執行 migration - 新增 migration 039 補充缺失欄位 **文件**: - src/core/db/postgres_db.rs: 修復 migration runner - src/main.rs: 添加 worker migration - migrations/039_add_missing_video_columns.sql: 新增缺失欄位 **測試**: 待 M5Max128 驗證 Ref: docs_v1.0/M4_workspace/2026-10-04_B-4_Deep_Fix_Plan.md
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
-- ================================================================
|
||||
-- Migration 039: Add Missing Video Columns
|
||||
-- Version: 039
|
||||
-- Date: 2026-10-04
|
||||
-- Description: Add missing columns to videos table that are missing
|
||||
-- from hardcoded DDL but required by worker
|
||||
-- ================================================================
|
||||
|
||||
-- 39.1: Add face_settings column
|
||||
ALTER TABLE videos ADD COLUMN IF NOT EXISTS face_settings JSONB;
|
||||
|
||||
COMMENT ON COLUMN videos.face_settings IS 'Face detection and recognition settings';
|
||||
|
||||
-- 39.2: Add asr_status column (if not exists from migration 036)
|
||||
ALTER TABLE videos ADD COLUMN IF NOT EXISTS asr_status VARCHAR(20) DEFAULT 'pending';
|
||||
|
||||
COMMENT ON COLUMN videos.asr_status IS 'ASR processing status: pending, processing, completed, failed';
|
||||
|
||||
-- 39.3: Add completed_at column
|
||||
ALTER TABLE videos ADD COLUMN IF NOT EXISTS completed_at TIMESTAMPTZ;
|
||||
|
||||
COMMENT ON COLUMN videos.completed_at IS 'Timestamp when video processing completed';
|
||||
|
||||
-- 39.4: Add vlm_description_localized column (from migration 038)
|
||||
ALTER TABLE videos ADD COLUMN IF NOT EXISTS vlm_description_localized JSONB DEFAULT '{}';
|
||||
|
||||
COMMENT ON COLUMN videos.vlm_description_localized IS 'Localized VLM descriptions by language code';
|
||||
|
||||
-- ================================================================
|
||||
-- Indexes for new columns
|
||||
-- ================================================================
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_videos_asr_status ON videos(asr_status)
|
||||
WHERE asr_status IS NOT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_videos_completed_at ON videos(completed_at)
|
||||
WHERE completed_at IS NOT NULL;
|
||||
Reference in New Issue
Block a user