"""Add confirm generation fields

Revision ID: 034
Revises: 033
Create Date: 2026-07-08

确认生成 API 改造：为 generation_tasks 表添加 is_preview、source_task_id、
output_width、output_height、cover_url、custom_title 字段。
"""

import sqlalchemy as sa

from alembic import op

revision = "034"
down_revision = "033"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "generation_tasks",
        sa.Column("is_preview", sa.Boolean(), nullable=False, server_default=sa.text("1")),
    )
    op.add_column(
        "generation_tasks",
        sa.Column("source_task_id", sa.String(32), nullable=False, server_default=""),
    )
    op.add_column(
        "generation_tasks",
        sa.Column("output_width", sa.Integer(), nullable=False, server_default=sa.text("1280")),
    )
    op.add_column(
        "generation_tasks",
        sa.Column("output_height", sa.Integer(), nullable=False, server_default=sa.text("720")),
    )
    op.add_column(
        "generation_tasks",
        sa.Column("cover_url", sa.String(1000), nullable=False, server_default=""),
    )
    op.add_column(
        "generation_tasks",
        sa.Column("custom_title", sa.String(500), nullable=False, server_default=""),
    )
    op.create_index(
        op.f("ix_generation_tasks_source_task_id"),
        "generation_tasks",
        ["source_task_id"],
    )


def downgrade() -> None:
    op.drop_index(op.f("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")
    op.drop_column("generation_tasks", "is_preview")
