fix(db): 移除 IncidentEvidence.incident_id 的重複 index 定義
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 14m50s

根本原因:incident_id 同時設定 index=True(mapped_column)
與 __table_args__ 中的 Index("ix_incident_evidence_incident_id"),
導致 table.create 生成重複的 CREATE INDEX,
觸發 "already exists" 被靜默捕捉,整個 CREATE TABLE transaction 回滾。
直接效果:Pod 啟動時 incident_evidence 表永遠不會被建立,
導致後續 ALTER TABLE 失敗 → CrashLoopBackOff。

修法:移除 mapped_column 中的 index=True,
索引由 __table_args__ 統一管理。

注意:已在 PostgreSQL 直接建立 incident_evidence 表解除 CrashLoop。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-15 16:13:18 +08:00
parent 655d1a568a
commit 4e2e6652e3

View File

@@ -759,7 +759,7 @@ class IncidentEvidence(Base):
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=generate_uuid)
# 關聯
incident_id: Mapped[str] = mapped_column(String(30), nullable=False, index=True)
incident_id: Mapped[str] = mapped_column(String(30), nullable=False) # index via __table_args__
# Phase 3 填充matched_playbook_id 目前永久 nullPhase 3 修復
matched_playbook_id: Mapped[str | None] = mapped_column(String(36), nullable=True)