from sqlalchemy import Column, Integer, String, DateTime, Index, Float, Boolean, Text, ForeignKey, Enum as SQLEnum from sqlalchemy.sql import func from sqlalchemy.orm import relationship from database import Base import enum class Locations(Base): __tablename__ = "location" id = Column(Integer, primary_key=True, nullable=False) country = Column(String(120), nullable=False) state = Column(String(100), nullable=False) city = Column(String(100), nullable=False) cp_zp = Column(Integer, nullable=True) street = Column(String(120), nullable=True) is_department = Column(Boolean, nullable=False, default=False) number_ext = Column(Integer, nullable=True) number_int = Column(Integer, nullable=True) is_active = Column(Boolean, default=True, nullable=False) #timestamsp created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False) updated_at = Column(DateTime(timezone=True), onupdate=func.now(), nullable=True) deleted_at = Column(DateTime, nullable=True) #trace created_by = Column(Integer, nullable=True) updated_by = Column(Integer, nullable=True) deleted_by = Column(Integer, nullable=True) #index __table_args__ = ( Index('idx_location_country','country'), Index('idx_location_state','state'), Index('idx_location_city','city'), Index('idx_location_cp','cp_zp'), Index('idx_location_active','is_active'), ) #relationships clients = relationship("Client",back_populates="location") branches = relationship("Branches",back_populates="location") credits = relationship("Credits",back_populates="location") licenses = relationship("License",back_populates="location")