"""Set progress to 1.0 for all tasks with status 'done'.

Revision ID: 0011
Revises: 0010
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "0011"
down_revision: Union[str, None] = "0010"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    conn = op.get_bind()
    conn.execute(
        sa.text("UPDATE tasks SET progress = 1.0 WHERE status = 'done' AND (progress IS NULL OR progress < 1.0)")
    )


def downgrade() -> None:
    # Data migration — no safe downgrade (we don't know the original progress values)
    pass
