"""
知识库数据库模型
"""
from sqlalchemy import Column, String, Integer, Text, Boolean
from sqlalchemy.dialects.mysql import CHAR, TINYINT
from app.base.async_mysql_connection import Base
from app.models.base import BaseModel


class KnowledgeBase(BaseModel):
    """知识库模型"""
    __tablename__ = "t_samp_knowledge_base"

    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(TINYINT, default=0, comment="是否删除")

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