Files
beige/backend/alembic/versions/006_image_role_varchar.py
yangqianqian 6a2632da70 baseline: Clover 独立仓库首次基线提交
将 Clover 从上层产品包旧仓库中独立出来,建立专属版本控制。
当前状态=纵切片端到端已打通(登录→选品→出文出图→审核→下载包),
M1文案质量去套路化已验收。此提交作为后续按核销清单逐条修复的基线。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 11:30:22 +08:00

46 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""006_image_role_varchar — image_candidates.role 从 enum 改 varchar(32)
根因storyboard 角色名仍在演进hook/product_closeup/ingredient/texture/
applied_proof/closer/pain_scene/social_proof/scenario/tutorial…固定 enum
每加一个新角色就要迁一次,且旧 enum 漏了 product_closeup/ingredient 直接导致
落库 "Data truncated for column 'role'" → 生图任务无限重试卡死。
改 varchar 后落库不再受 enum 约束,角色名由 ImageRole 枚举在应用层定义。
"""
from alembic import op
import sqlalchemy as sa
revision = "006"
down_revision = "005"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.alter_column(
"image_candidates",
"role",
existing_type=sa.Enum(
"hook", "pain", "proof", "quality", "credit", "convert", "main",
name="role",
),
type_=sa.String(32),
existing_nullable=False,
server_default="hook",
comment="分镜角色名storyboard 输出,应用层 ImageRole 定义,不在 DB 约束)",
)
def downgrade() -> None:
op.alter_column(
"image_candidates",
"role",
existing_type=sa.String(32),
type_=sa.Enum(
"hook", "pain", "proof", "quality", "credit", "convert", "main",
name="role",
),
existing_nullable=False,
server_default="main",
)