from sqlalchemy import Boolean, Integer, String, ForeignKey, Index from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base, TimestampMixin class MenuConfig(Base, TimestampMixin): __tablename__ = "menu_configs" id: Mapped[str] = mapped_column(String(32), primary_key=True) label: Mapped[str] = mapped_column(String(64)) path: Mapped[str] = mapped_column(String(128), default="") icon: Mapped[str] = mapped_column(String(64), default="") sort_order: Mapped[int] = mapped_column(Integer, default=0) is_active: Mapped[bool] = mapped_column(Boolean, default=True) parent_id: Mapped[str | None] = mapped_column(String(32), ForeignKey("menu_configs.id"), nullable=True, index=True) menu_type: Mapped[str] = mapped_column(String(16), default="page") menu_target: Mapped[str] = mapped_column(String(16), default="frontend") is_default: Mapped[bool] = mapped_column(Boolean, default=False) __table_args__ = ( Index('idx_menu_target_active_sort', 'menu_target', 'is_active', 'sort_order'), )