from sqlalchemy import Column, Integer, String, Text, ForeignKey, DateTime, Boolean
from sqlalchemy.orm import relationship
from datetime import datetime
from ..config.database import Base

class GuestNote(Base):
    __tablename__ = 'guest_notes'
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    user_id = Column(Integer, ForeignKey('users.id'), nullable=False, index=True)
    created_by = Column(Integer, ForeignKey('users.id'), nullable=False)  # Staff/admin who created the note
    note = Column(Text, nullable=False)
    is_important = Column(Boolean, nullable=False, default=False)
    is_private = Column(Boolean, nullable=False, default=False)  # Private notes only visible to admins
    created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
    
    user = relationship('User', foreign_keys=[user_id], back_populates='guest_notes')
    creator = relationship('User', foreign_keys=[created_by])

