"""drop step_stars — the starring feature was reverted

Revision ID: d5f2a08c31be
Revises: c4a7e91b6d20
Create Date: 2026-09-01

The feature it backed was built outside rian's M2 mandate and pulled. The
CREATE migration (c4a7e91b6d20) is deliberately left in place rather than
deleted: production has already stamped that revision, and removing a migration
the database has run leaves alembic unable to locate its own head at boot.
Forward-only, like every other schema change here.
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = 'd5f2a08c31be'
down_revision: Union[str, Sequence[str], None] = 'c4a7e91b6d20'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.drop_index(op.f('ix_step_stars_username'), table_name='step_stars')
    op.drop_index(op.f('ix_step_stars_step_id'), table_name='step_stars')
    op.drop_table('step_stars')


def downgrade() -> None:
    op.create_table(
        'step_stars',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('step_id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=64), nullable=False),
        sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(['step_id'], ['walkthrough_steps.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('step_id', 'username', name='uq_step_star_who'),
    )
    op.create_index(op.f('ix_step_stars_step_id'), 'step_stars', ['step_id'],
                    unique=False)
    op.create_index(op.f('ix_step_stars_username'), 'step_stars', ['username'],
                    unique=False)
