"""step_stars: "I like this bit" on a walkthrough beat

Revision ID: c4a7e91b6d20
Revises: 8b3d1f5a2c47
Create Date: 2026-09-01
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

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


def upgrade() -> 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)


def downgrade() -> 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')
