""" update obselete transition names in history

Revision ID: 8652789edda9
Revises: 0147b747696e
Create Date: 2024-10-01 01:18:46.781652
"""

from alembic import op
import sqlalchemy as sa
import hiboo


revision = "8652789edda9"
down_revision = "0147b747696e"
branch_labels = None
depends_on = None

history_table = sa.Table(
    "history",
    sa.MetaData(),
    sa.Column("category", sa.String(length=25), nullable=True),
    sa.Column("value", sa.String(), nullable=True),
)


def upgrade():
    connection = op.get_bind()
    connection.execute(
        history_table.update()
        .where(
            sa.and_(
                history_table.c.category == "transition",
                sa.or_(
                    history_table.c.value == "purge-deleted",
                    history_table.c.value == "purge-blocked",
                ),
            )
        )
        .values(value="purge")
    )
    connection.execute(
        history_table.update()
        .where(
            sa.and_(
                history_table.c.category == "transition",
                history_table.c.value == "delete-blocked",
            )
        )
        .values(value="delete")
    )


def downgrade():
    """I don't think there will be a return journey"""
    pass