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

class RoomAttribute(Base):
    __tablename__ = 'room_attributes'
    
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    room_id = Column(Integer, ForeignKey('rooms.id'), nullable=False, index=True)
    
    # Attribute details
    attribute_name = Column(String(100), nullable=False)  # e.g., 'view_quality', 'noise_level', 'accessibility'
    attribute_value = Column(String(255), nullable=True)  # e.g., 'ocean_view', 'quiet', 'wheelchair_accessible'
    attribute_data = Column(JSON, nullable=True)  # Additional structured data
    
    # Tracking
    last_updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
    updated_by = Column(Integer, ForeignKey('users.id'), nullable=True)
    notes = Column(Text, nullable=True)
    
    # Status
    is_active = Column(Boolean, nullable=False, default=True)
    
    created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
    
    # Relationships
    room = relationship('Room', back_populates='attributes')
    updater = relationship('User')

