"""initial_schema

Revision ID: 2f4936eb86f0
Revises: 
Create Date: 2025-12-02 21:34:08.468033

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '2f4936eb86f0'
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:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('bus_stops',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('latitude', sa.Float(), nullable=False),
    sa.Column('longitude', sa.Float(), nullable=False),
    sa.Column('city', sa.String(), nullable=False),
    sa.Column('address', sa.String(), nullable=True),
    sa.Column('stop_type', sa.Enum('TERMINAL', 'REGULAR', 'EXPRESS_ONLY', name='stoptype'), nullable=False),
    sa.Column('has_shelter', sa.Boolean(), nullable=False),
    sa.Column('has_seating', sa.Boolean(), nullable=False),
    sa.Column('is_accessible', sa.Boolean(), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('routes',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('origin_city', sa.String(), nullable=False),
    sa.Column('destination_city', sa.String(), nullable=False),
    sa.Column('distance_km', sa.Float(), nullable=True),
    sa.Column('estimated_duration_minutes', sa.Integer(), nullable=True),
    sa.Column('status', sa.Enum('ACTIVE', 'INACTIVE', 'MAINTENANCE', name='routestatus'), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_routes_name'), 'routes', ['name'], unique=True)
    op.create_table('bus_schedules',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('route_id', sa.Uuid(), nullable=False),
    sa.Column('departure_time', sa.Time(), nullable=False),
    sa.Column('frequency_minutes', sa.Integer(), nullable=True),
    sa.Column('schedule_type', sa.Enum('WEEKDAY', 'WEEKEND', 'HOLIDAY', name='busscheduletype'), nullable=False),
    sa.Column('is_active', sa.Boolean(), nullable=False),
    sa.Column('notes', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['route_id'], ['routes.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('route_stops',
    sa.Column('id', sa.Uuid(), nullable=False),
    sa.Column('route_id', sa.Uuid(), nullable=False),
    sa.Column('stop_id', sa.Uuid(), nullable=False),
    sa.Column('stop_order', sa.Integer(), nullable=False),
    sa.Column('travel_time_minutes', sa.Integer(), nullable=True),
    sa.Column('is_pickup_point', sa.Boolean(), nullable=False),
    sa.Column('is_dropoff_point', sa.Boolean(), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['route_id'], ['routes.id'], ),
    sa.ForeignKeyConstraint(['stop_id'], ['bus_stops.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('route_stops')
    op.drop_table('bus_schedules')
    op.drop_index(op.f('ix_routes_name'), table_name='routes')
    op.drop_table('routes')
    op.drop_table('bus_stops')
    # ### end Alembic commands ###

