"""add evolutions table and current_pokemon_id to encounters

Revision ID: b2c3d4e5f6a7
Revises: a1b2c3d4e5f6
Create Date: 2026-02-05 18:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


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


def upgrade() -> None:
    op.create_table(
        'evolutions',
        sa.Column('id', sa.Integer(), primary_key=True),
        sa.Column('from_pokemon_id', sa.Integer(), sa.ForeignKey('pokemon.id'), nullable=False, index=True),
        sa.Column('to_pokemon_id', sa.Integer(), sa.ForeignKey('pokemon.id'), nullable=False, index=True),
        sa.Column('trigger', sa.String(30), nullable=False),
        sa.Column('min_level', sa.SmallInteger(), nullable=True),
        sa.Column('item', sa.String(50), nullable=True),
        sa.Column('held_item', sa.String(50), nullable=True),
        sa.Column('condition', sa.String(200), nullable=True),
    )

    op.add_column(
        'encounters',
        sa.Column('current_pokemon_id', sa.Integer(), sa.ForeignKey('pokemon.id'), nullable=True, index=True),
    )


def downgrade() -> None:
    op.drop_column('encounters', 'current_pokemon_id')
    op.drop_table('evolutions')
