fix(migration): rename 3002 to 002 for correct execution order
**問題** (M4 報告): - 36/41 migration 失敗 - 3002 排在最後,基礎表未建立 - 導致 relation/column does not exist **修復**: - 重命名 3002_public_schema_pipeline_tables.sql → 002 - 確保基礎表在第 2 位建立 **預期**: - 41/41 migration 成功 - videos.face_settings 欄位存在 **清理**: - 移除錯誤提交的備份檔 Ref: docs_v1.0/M4_workspace/2026-10-04_B-4_Sorting_Fix.md
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
# B-4 Migration 排序修復
|
||||
|
||||
**日期**: 2026-10-04
|
||||
**問題**: 36/41 migration 失敗
|
||||
**原因**: 3002 排在最後,基礎表未建立
|
||||
|
||||
---
|
||||
|
||||
## 問題分析
|
||||
|
||||
### 失敗原因
|
||||
|
||||
**排序錯誤**:
|
||||
- `3002_public_schema_pipeline_tables.sql` 排在第 41 位
|
||||
- 它建立基礎表(videos, talents, chunks)
|
||||
- 前面 36 個 migration 已經對這些表做 ALTER/RENAME
|
||||
|
||||
**連鎖失敗**:
|
||||
```
|
||||
003_job_worker.sql → column "video_id" does not exist
|
||||
006_face_recognition.sql → column "video_uuid" does not exist
|
||||
008_person_identity.sql → relation "chunks" does not exist
|
||||
012_rename_to_identities → relation "public.talents" does not exist
|
||||
...
|
||||
```
|
||||
|
||||
### 成功的 5 個 migration
|
||||
|
||||
1. 001_api_key_management.sql
|
||||
2. 005_change_duration_float.sql
|
||||
3. 007_person_identity_tables.sql
|
||||
4. 017_create_pre_chunks.sql
|
||||
5. 020_create_mac_allocations.sql
|
||||
|
||||
---
|
||||
|
||||
## 修復方案
|
||||
|
||||
### 方案 1:改檔名(實作)
|
||||
|
||||
**修改**:
|
||||
- `3002_public_schema_pipeline_tables.sql` → `002_public_schema_pipeline_tables.sql`
|
||||
|
||||
**效果**:
|
||||
- 確保基礎表在第 2 位建立
|
||||
- 後續 migration 可以正確執行 ALTER/RENAME
|
||||
|
||||
**新的排序**:
|
||||
```
|
||||
001_api_key_management.sql
|
||||
002_public_schema_pipeline_tables.sql ← 移到前面
|
||||
003_job_worker.sql
|
||||
004_fix_processor_results.sql
|
||||
005_change_duration_float.sql
|
||||
...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 預期結果
|
||||
|
||||
### Migration 成功率
|
||||
|
||||
- **之前**: 5/41 (12%)
|
||||
- **預期**: 41/41 (100%)
|
||||
|
||||
### 欄位驗證
|
||||
|
||||
- `videos.face_settings` ✅
|
||||
- `videos.asr_status` ✅
|
||||
- `videos.completed_at` ✅
|
||||
|
||||
---
|
||||
|
||||
## 長期方案
|
||||
|
||||
### 移除硬編碼 DDL
|
||||
|
||||
**問題**: `postgres_db.rs:1076-1640` 的 570 行 hardcoded CREATE TABLE 與 SQL 檔案並存
|
||||
|
||||
**建議**:
|
||||
1. 逐步移除硬編碼 DDL
|
||||
2. 統一使用 .sql migration
|
||||
3. 避免兩套機制衝突
|
||||
|
||||
---
|
||||
|
||||
## 下一步
|
||||
|
||||
1. ✅ 重命名 migration
|
||||
2. ⏸️ 構建 binary
|
||||
3. ⏸️ M5Max128 測試
|
||||
4. ⏸️ 驗證 41/41 成功
|
||||
|
||||
---
|
||||
|
||||
**責任**: Core Team
|
||||
**目標**: 100% migration 成功率
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user