"""
Dashboard Models
"""
from sqlalchemy import Column, Integer, String, Text, ForeignKey
from app.core.database import Base


class Dashboard(Base):
    """Dashboards table"""
    __tablename__ = "dashboards"
    
    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(Text, nullable=False)
    user_id = Column(Text, nullable=False)
    agent_id = Column(Text, nullable=False)
    created_at = Column(Text, nullable=False)
    updated_at = Column(Text, nullable=False)
    # Use 'metadata_' as attribute name but 'metadata' as column name
    metadata_ = Column("metadata", Text, default="")


class Section(Base):
    """Dashboard sections table"""
    __tablename__ = "sections"
    
    id = Column(Integer, primary_key=True, autoincrement=True)
    dashboard_id = Column(Text, ForeignKey("dashboards.id", ondelete="CASCADE"), nullable=False)
    name = Column(Text, nullable=False)
    height = Column(Integer, nullable=False)
    width = Column(Integer, nullable=False)
    url = Column(Text)
    position_x = Column(Integer, default=0)
    position_y = Column(Integer, default=0)
    created_at = Column(Text, nullable=False)
    updated_at = Column(Text, nullable=False)
    # Use 'metadata_' as attribute name but 'metadata' as column name
    metadata_ = Column("metadata", Text, default="")
