from datetime import datetime from sqlalchemy import Boolean, DateTime, Integer, String, Text, func from sqlalchemy.orm import Mapped, mapped_column from app.db.base import Base class SystemConfig(Base): __tablename__ = "system_configs" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) config_key: Mapped[str] = mapped_column(String(100), nullable=False, unique=True, index=True) category: Mapped[str] = mapped_column(String(50), nullable=False, index=True) title: Mapped[str] = mapped_column(String(200), nullable=False) config_json: Mapped[str] = mapped_column(Text, nullable=False, default="{}") description: Mapped[str | None] = mapped_column(Text) is_active: Mapped[bool] = mapped_column(Boolean, default=True, index=True) sort_order: Mapped[int] = mapped_column(Integer, default=0) updated_by: Mapped[int | None] = mapped_column(Integer) 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()) def __repr__(self) -> str: return f""