from sqlalchemy import Column, String, Boolean, DateTime, Integer, ForeignKey from sqlalchemy.sql import func from app.core.database.db_session import Base class TechnicianProfile(Base): __tablename__ = "technician_profiles" technician_id = Column(String(26), primary_key=True) user_id = Column(String(26), nullable=False, unique=True, index=True) active = Column(Boolean, default=True) class TechnicianSkill(Base): __tablename__ = "technician_skills" technician_id = Column(String(26), ForeignKey("technician_profiles.technician_id", ondelete="CASCADE"), primary_key=True) service_type_id = Column(String(26), primary_key=True) # References CRM service_types table skill_level = Column(Integer, default=1) class TechnicianWorkingHours(Base): __tablename__ = "technician_working_hours" working_hour_id = Column(String(26), primary_key=True) technician_id = Column(String(26), ForeignKey("technician_profiles.technician_id", ondelete="CASCADE"), nullable=False, index=True) day_of_week = Column(Integer, nullable=False) # 0-6 (Monday-Sunday) start_time = Column(String(5), nullable=False) # e.g., "09:00" end_time = Column(String(5), nullable=False) # e.g., "18:00" class TechnicianLeave(Base): __tablename__ = "technician_leaves" leave_id = Column(String(26), primary_key=True) technician_id = Column(String(26), ForeignKey("technician_profiles.technician_id", ondelete="CASCADE"), nullable=False, index=True) start_datetime = Column(DateTime, nullable=False) end_datetime = Column(DateTime, nullable=False) reason = Column(String(255), nullable=True)