from datetime import datetime from sqlalchemy import DateTime, Integer, String, Text, func from sqlalchemy.orm import Mapped, mapped_column from app.db.session import Base class KnowledgeItem(Base): __tablename__ = "knowledge_items" id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True) title: Mapped[str] = mapped_column(String(250), nullable=False, index=True) category: Mapped[str] = mapped_column(String(80), nullable=False, default="未分类") content: Mapped[str] = mapped_column(Text, nullable=False) source_url: Mapped[str | None] = mapped_column(String(1000), nullable=True) verification_status: Mapped[str] = mapped_column(String(30), nullable=False, default="pending") created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())