""" Copyright 2024-2026 ReplyPier Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from sqlalchemy import Column, Integer, ForeignKey, DateTime, func from sqlalchemy.orm import relationship from app.database import Base from sqlalchemy.dialects.postgresql import UUID class KnowledgeToAgent(Base): __tablename__ = "knowledge_to_agents" id = Column(Integer, primary_key=True, index=True) knowledge_id = Column(Integer, ForeignKey( "knowledge.id", ondelete="CASCADE"), nullable=False) agent_id = Column(UUID(as_uuid=True), ForeignKey( "agents.id", ondelete="CASCADE"), nullable=False) created_at = Column(DateTime, server_default=func.now()) updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now()) # Relationships knowledge = relationship("Knowledge", back_populates="agent_links") agent = relationship("Agent", back_populates="knowledge_links")