from core.database import Base
from datetime import datetime
from sqlalchemy import Column, DateTime, Integer, String


class Chat_conversations(Base):
    __tablename__ = "chat_conversations"
    __table_args__ = {"extend_existing": True}

    id = Column(Integer, primary_key=True, index=True, autoincrement=True, nullable=False)
    user_id = Column(String, nullable=True)
    whmcs_client_id = Column(Integer, nullable=True)
    visitor_name = Column(String, nullable=True)
    visitor_email = Column(String, nullable=True)
    department_id = Column(Integer, nullable=True)
    assigned_seat_id = Column(Integer, nullable=True)
    status = Column(String, nullable=False)
    priority = Column(String, nullable=False)
    sla_due_at = Column(DateTime(timezone=True), nullable=True)
    linked_whmcs_service_id = Column(Integer, nullable=True)
    linked_whmcs_invoice_id = Column(Integer, nullable=True)
    linked_whmcs_domain_id = Column(Integer, nullable=True)
    linked_ticket_id = Column(Integer, nullable=True)
    ai_summary = Column(String, nullable=True)
    last_message_at = Column(DateTime(timezone=True), nullable=True)
    subject = Column(String, nullable=True)
    created_at = Column(DateTime(timezone=True), default=datetime.now)
    updated_at = Column(DateTime(timezone=True), default=datetime.now, onupdate=datetime.now)