"""initial registrations table

Revision ID: 0001
Revises:
Create Date: 2026-06-22

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision: str = "0001"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "registrations",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("registration_id", sa.String(length=32), nullable=False),
        sa.Column("name", sa.String(length=120), nullable=False),
        sa.Column("email", sa.String(length=180), nullable=False),
        sa.Column("phone", sa.String(length=20), nullable=False),
        sa.Column("age", sa.Integer(), nullable=False),
        sa.Column("city", sa.String(length=120), nullable=False),
        sa.Column("blood_group", sa.String(length=8), nullable=False),
        sa.Column("experience", sa.String(length=40), nullable=False),
        sa.Column("weekly_km", sa.Integer(), nullable=False),
        sa.Column("leg_choice", sa.String(length=16), nullable=False),
        sa.Column("needs_rental", sa.Boolean(), nullable=False),
        sa.Column("tshirt_size", sa.String(length=4), nullable=False),
        sa.Column("emergency_contact_name", sa.String(length=120), nullable=False),
        sa.Column("emergency_contact_phone", sa.String(length=20), nullable=False),
        sa.Column("medical_fitness_confirmed", sa.Boolean(), nullable=False),
        sa.Column(
            "registered_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("CURRENT_TIMESTAMP"),
            nullable=False,
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        "ix_registrations_registration_id",
        "registrations",
        ["registration_id"],
        unique=True,
    )
    op.create_index(
        "ix_registrations_email",
        "registrations",
        ["email"],
        unique=False,
    )


def downgrade() -> None:
    op.drop_index("ix_registrations_email", table_name="registrations")
    op.drop_index("ix_registrations_registration_id", table_name="registrations")
    op.drop_table("registrations")
