"""phase3: add parse_mode, template_name, error_details columns

Revision ID: c7a3f8e21d4b
Revises: 513b48dbb16c
Create Date: 2026-02-27 13:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'c7a3f8e21d4b'
down_revision: Union[str, None] = '513b48dbb16c'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # Add parse_mode to master_decks (P1-2: slide-based parsing mode)
    op.add_column('master_decks', sa.Column('parse_mode', sa.String(), nullable=True))

    # Add template_name to presentations (P0-3: template selection in worker)
    op.add_column('presentations', sa.Column('template_name', sa.String(), nullable=True))

    # Add error_details to ai_usage_logs (P2-2: image generation error visibility)
    op.add_column('ai_usage_logs', sa.Column('error_details', sa.String(), nullable=True))


def downgrade() -> None:
    op.drop_column('ai_usage_logs', 'error_details')
    op.drop_column('presentations', 'template_name')
    op.drop_column('master_decks', 'parse_mode')
