from datetime import datetime



from sqlalchemy import DateTime, String, Text, UniqueConstraint, func

from sqlalchemy.orm import Mapped, mapped_column



from app.database import Base





class Config(Base):

    __tablename__ = "configs"

    __table_args__ = (UniqueConstraint("name", name="uq_configs_name"),)



    id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)

    name: Mapped[str] = mapped_column(String(64), index=True)

    value: Mapped[str] = mapped_column(Text)

    mark: Mapped[str | None] = mapped_column(String(255), nullable=True, default=None)

    created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())

    updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())

