# modules/calendar/models.py
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, JSON # Add JSON
from sqlalchemy.orm import relationship
from core.database import Base

class CalendarEvent(Base):
    __tablename__ = "calendar_events"

    id = Column(Integer, primary_key=True)
    title = Column(String, nullable=False)
    description = Column(String)
    start = Column(DateTime, nullable=False)
    end = Column(DateTime)
    location = Column(String)
    tags = Column(JSON)
    color = Column(String) # hex code for color
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False)  # <-- Relationship

    # Bi-directional relationship (for eager loading)
    user = relationship("User", back_populates="calendar_events")