"""Add generated video management fields.

Revision ID: 005
Revises: 004
Create Date: 2026-06-24
"""

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

revision: str = "005"
down_revision: Union[str, None] = "004"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "generated_videos", sa.Column("status", sa.String(length=20), nullable=False, server_default="completed")
    )
    op.add_column(
        "generated_videos",
        sa.Column("review_status", sa.String(length=20), nullable=False, server_default="pending_review"),
    )
    op.add_column("generated_videos", sa.Column("generation_params", sa.Text(), nullable=False, server_default="{}"))
    op.add_column("generated_videos", sa.Column("updated_at", sa.DateTime(), nullable=True))
    op.create_index(op.f("ix_generated_videos_status"), "generated_videos", ["status"], unique=False)
    op.create_index(op.f("ix_generated_videos_review_status"), "generated_videos", ["review_status"], unique=False)


def downgrade() -> None:
    op.drop_index(op.f("ix_generated_videos_review_status"), table_name="generated_videos")
    op.drop_index(op.f("ix_generated_videos_status"), table_name="generated_videos")
    op.drop_column("generated_videos", "updated_at")
    op.drop_column("generated_videos", "generation_params")
    op.drop_column("generated_videos", "review_status")
    op.drop_column("generated_videos", "status")
