"""Route stop junction model."""
from sqlmodel import SQLModel, Field, Column
from datetime import datetime
from typing import Optional
from uuid import UUID, uuid4
from sqlalchemy import DateTime, func


class RouteStop(SQLModel, table=True):
    """Route stop junction table connecting routes to their stops."""
    
    __tablename__ = "route_stops"
    
    id: Optional[UUID] = Field(default_factory=uuid4, primary_key=True)
    route_id: UUID = Field(foreign_key="routes.id")
    stop_id: UUID = Field(foreign_key="bus_stops.id")
    stop_order: int
    travel_time_minutes: Optional[int] = None
    stop_delay_minutes: int = 0
    is_pickup_point: bool = True
    is_dropoff_point: bool = True
    created_at: Optional[datetime] = Field(sa_column=Column(DateTime, server_default=func.now()))

