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

class Service(Base):
    __tablename__ = 'services'
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    name = Column(String(100), nullable=False)
    description = Column(Text, nullable=True)
    price = Column(Numeric(10, 2), nullable=False)
    category = Column(String(50), nullable=True)
    slug = Column(String(200), nullable=True, unique=True, index=True)
    image = Column(String(1000), nullable=True)
    content = Column(Text, nullable=True)
    sections = Column(Text, nullable=True)  # JSON string for advanced content blocks
    meta_title = Column(String(500), nullable=True)
    meta_description = Column(Text, nullable=True)
    meta_keywords = Column(String(1000), nullable=True)
    is_active = Column(Boolean, nullable=False, default=True)
    created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
    service_usages = relationship('ServiceUsage', back_populates='service')