from datetime import datetime
from typing import Optional
import uuid
from sqlalchemy import Column, DateTime, ForeignKey, Boolean
from sqlmodel import Field, SQLModel
from utils.datetime_utils import get_current_utc_datetime


class TeamModel(SQLModel, table=True):
    __tablename__ = "teams"

    id: uuid.UUID = Field(primary_key=True, default_factory=uuid.uuid4)
    name: str
    client_id: Optional[uuid.UUID] = Field(
        sa_column=Column(ForeignKey("clients.id"), nullable=True), default=None
    )
    is_default: bool = Field(sa_column=Column(Boolean, default=False, nullable=False))
    created_at: datetime = Field(
        sa_column=Column(
            DateTime(timezone=True), nullable=False, default=get_current_utc_datetime
        ),
    )
