23 lines
934 B
Python
23 lines
934 B
Python
from sqlalchemy import Column, Integer, String, Boolean, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from app.db.database import Base
|
|
|
|
class Contractor(Base):
|
|
__tablename__ = "contractors"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False)
|
|
ruc = Column(String, unique=True)
|
|
contact_name = Column(String)
|
|
email = Column(String, nullable=True)
|
|
phone = Column(String, nullable=True)
|
|
address = Column(String, nullable=True)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
specialty_id = Column(Integer, ForeignKey("specialties.id"), nullable=True)
|
|
parent_id = Column(Integer, ForeignKey("contractors.id"), nullable=True)
|
|
|
|
specialty = relationship("app.models.specialty.Specialty")
|
|
parent = relationship("Contractor", remote_side=[id], back_populates="subcontractors")
|
|
subcontractors = relationship("Contractor", back_populates="parent")
|