"""Taxi 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 Taxi(SQLModel, table=True):
    """Taxi model representing an authorized taxi."""
    
    __tablename__ = "taxis_v2"
    
    id: Optional[UUID] = Field(default_factory=uuid4, primary_key=True)
    owner_name: str
    phone_number: str
    license_plate: str = Field(unique=True, index=True)
    cooperative: Optional[str] = None
    corregimiento: str = Field(index=True)
    shift: str = "day" # day, night, 24h
    rating: float = Field(default=5.0)
    english_speaking: bool = Field(default=False)
    image_url: Optional[str] = None
    is_active: bool = Field(default=True)
    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()))
