cf55d475b9
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 43s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 48s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 49s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m21s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m42s
AI Code Review / AI Code Review (pull_request) Failing after 2m10s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m48s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m49s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m24s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 3m52s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m30s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 7m6s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 6s
83 lines
2.4 KiB
Python
83 lines
2.4 KiB
Python
"""确认生成 API 改造:为 generation_tasks 表添加 source_task_id、output_width、output_height、cover_url、custom_title 字段
|
|
|
|
Revision ID: 054_confirm_gen_fields
|
|
Revises: 053_generation_task_is_preview
|
|
Create Date: 2026-08-16
|
|
|
|
Changes:
|
|
1. generation_tasks 表新增 source_task_id(来源预览任务 ID,带索引)
|
|
2. generation_tasks 表新增 output_width / output_height(动态输出分辨率)
|
|
3. generation_tasks 表新增 cover_url / custom_title(自定义封面和标题)
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision = "054_confirm_gen_fields"
|
|
down_revision = "053_generation_task_is_preview"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
conn = op.get_bind()
|
|
is_pg = conn.dialect.name == "postgresql"
|
|
|
|
if is_pg:
|
|
# 幂等检查:source_task_id 列是否已存在
|
|
result = conn.execute(
|
|
sa.text(
|
|
"SELECT column_name FROM information_schema.columns "
|
|
"WHERE table_name = 'generation_tasks' AND column_name = 'source_task_id'"
|
|
)
|
|
)
|
|
if result.scalar() is not None:
|
|
return
|
|
|
|
# source_task_id
|
|
op.add_column(
|
|
"generation_tasks",
|
|
sa.Column("source_task_id", sa.String(32), nullable=False, server_default=""),
|
|
)
|
|
|
|
# output_width
|
|
op.add_column(
|
|
"generation_tasks",
|
|
sa.Column("output_width", sa.Integer, nullable=False, server_default=sa.text("1280")),
|
|
)
|
|
|
|
# output_height
|
|
op.add_column(
|
|
"generation_tasks",
|
|
sa.Column("output_height", sa.Integer, nullable=False, server_default=sa.text("720")),
|
|
)
|
|
|
|
# cover_url
|
|
op.add_column(
|
|
"generation_tasks",
|
|
sa.Column("cover_url", sa.String(1000), nullable=False, server_default=""),
|
|
)
|
|
|
|
# custom_title
|
|
op.add_column(
|
|
"generation_tasks",
|
|
sa.Column("custom_title", sa.String(500), nullable=False, server_default=""),
|
|
)
|
|
|
|
# 索引
|
|
op.create_index(
|
|
"ix_generation_tasks_source_task_id",
|
|
"generation_tasks",
|
|
["source_task_id"],
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_generation_tasks_source_task_id", table_name="generation_tasks")
|
|
op.drop_column("generation_tasks", "custom_title")
|
|
op.drop_column("generation_tasks", "cover_url")
|
|
op.drop_column("generation_tasks", "output_height")
|
|
op.drop_column("generation_tasks", "output_width")
|
|
op.drop_column("generation_tasks", "source_task_id")
|