first commit
This commit is contained in:
45
app/modules/license/models.py
Normal file
45
app/modules/license/models.py
Normal file
@@ -0,0 +1,45 @@
|
||||
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 License(Base):
|
||||
__tablename__ = "license"
|
||||
|
||||
id = Column(Integer, primary_key=True, nullable=False, autoincrement=True)
|
||||
titular = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
|
||||
begins_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
ends_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
|
||||
token_license = Column(String(30), nullable=True)
|
||||
location_id = Column(Integer, ForeignKey("location.id"), nullable=False)
|
||||
client_id = Column(Integer, ForeignKey("clients.id"), 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(timezone=True), nullable=False)
|
||||
|
||||
#trace
|
||||
created_by = Column(Integer, nullable=True)
|
||||
updated_by = Column(Integer, nullable=True)
|
||||
deleted_by = Column(Integer, nullable=True)
|
||||
|
||||
__table_arg__ = (
|
||||
Index('idx_license_token', 'token_license'),
|
||||
Index('idx_license_client', 'client_id'),
|
||||
Index('idx_license_active', 'is_active'),
|
||||
Index('idx_license_ends_at', 'ends_at'),
|
||||
)
|
||||
|
||||
#Relations
|
||||
client = relationship("Client", foreign_keys=[client_id], back_populates="license")
|
||||
location = relationship("Locations", foreign_keys=[location_id], back_populates="licenses")
|
||||
user = relationship("Users", foreign_keys=[titular], back_populates="licenses")
|
||||
Reference in New Issue
Block a user