36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""Bus stop model."""
|
|
from sqlmodel import SQLModel, Field, Column
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from enum import Enum
|
|
from uuid import UUID, uuid4
|
|
from sqlalchemy import DateTime, func
|
|
|
|
|
|
class StopType(str, Enum):
|
|
"""Stop type enumeration."""
|
|
TERMINAL = "terminal"
|
|
REGULAR = "regular"
|
|
EXPRESS_ONLY = "express_only"
|
|
|
|
|
|
class BusStop(SQLModel, table=True):
|
|
"""Bus stop model."""
|
|
|
|
__tablename__ = "bus_stops"
|
|
|
|
id: Optional[UUID] = Field(default_factory=uuid4, primary_key=True)
|
|
name: str
|
|
latitude: float
|
|
longitude: float
|
|
city: str
|
|
address: Optional[str] = None
|
|
stop_type: StopType = StopType.REGULAR
|
|
has_shelter: bool = False
|
|
has_seating: bool = False
|
|
is_accessible: bool = False
|
|
stop_order: Optional[int] = None
|
|
created_at: Optional[datetime] = Field(sa_column=Column(DateTime, server_default=func.now()))
|
|
updated_at: Optional[datetime] = Field(sa_column=Column(DateTime, server_default=func.now(), onupdate=func.now()))
|
|
|