"""
知识库数据库模型
"""
from sqlalchemy import Column, String, Integer, Text
from app.base.async_mysql_connection import Base

class KnowledgeBase(Base):
    """知识库模型"""
    __tablename__ = "knowledge_base"

    id = Column(String(36), primary_key=True, comment="ID")
    name = Column(String(100), nullable=False, comment="知识库名称")
    collection_name = Column(String(100), nullable=False, unique=True, comment="Milvus集合名称(Table Name)")
    description = Column(Text, nullable=True, comment="描述")
    status = Column(String(20), default="normal", comment="状态: normal(正常), test(测试), disabled(禁用)")
    document_count = Column(Integer, default=0, comment="文档数量")
    is_deleted = Column(Integer, default=0, comment="是否删除")
    created_at = Column(String(32), comment="创建时间")
    updated_at = Column(String(32), comment="更新时间")

    def __repr__(self):
        return f"<KnowledgeBase {self.name}>"
