mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 07:19:35 +00:00
21 lines
970 B
Python
21 lines
970 B
Python
from sqlalchemy import Column, String, Text, DateTime, ForeignKey
|
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
|
from sqlalchemy.orm import relationship
|
|
from app.models.base import TenantModel
|
|
|
|
|
|
class Message(TenantModel):
|
|
__tablename__ = "messages"
|
|
|
|
lead_id = Column(UUID(as_uuid=True), ForeignKey("leads.id"), nullable=True)
|
|
customer_id = Column(UUID(as_uuid=True), ForeignKey("customers.id"), nullable=True)
|
|
channel = Column(String(50), nullable=False) # whatsapp, email, sms
|
|
direction = Column(String(10), nullable=False) # inbound, outbound
|
|
content = Column(Text)
|
|
status = Column(String(50), default="pending") # pending, sent, delivered, read, failed
|
|
sent_at = Column(DateTime(timezone=True))
|
|
extra_metadata = Column(JSONB, default=dict)
|
|
|
|
lead = relationship("Lead", back_populates="messages", foreign_keys=[lead_id])
|
|
customer = relationship("Customer", back_populates="messages", foreign_keys=[customer_id])
|