| 12345678910111213141516171819202122 |
- from datetime import datetime
- from sqlalchemy import DateTime, String, Text
- from sqlalchemy.dialects.sqlite import JSON
- from sqlalchemy.orm import Mapped, mapped_column
- from core_db import AuditMixin, Base, TenantMixin, VersionMixin
- from core_shared import JSONValue
- class KnowledgeDocument(TenantMixin, AuditMixin, VersionMixin, Base):
- __tablename__ = "knowledge_document"
- knowledge_base_id: Mapped[str] = mapped_column(String(36), index=True)
- title: Mapped[str] = mapped_column(String(256))
- source_type: Mapped[str] = mapped_column(String(32), default="text", index=True)
- source_uri: Mapped[str | None] = mapped_column(String(512), nullable=True)
- status: Mapped[str] = mapped_column(String(32), default="draft", index=True)
- content_text: Mapped[str] = mapped_column(Text)
- content_hash: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
- metadata_json: Mapped[dict[str, JSONValue] | None] = mapped_column(JSON, nullable=True)
- indexed_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|