first commit
This commit is contained in:
BIN
app/modules/moves/__pycache__/models.cpython-311.pyc
Normal file
BIN
app/modules/moves/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
71
app/modules/moves/models.py
Normal file
71
app/modules/moves/models.py
Normal file
@@ -0,0 +1,71 @@
|
||||
from sqlalchemy import Column, Integer, String, Date, Index, DateTime, Float, Boolean, Text, ForeignKey, Enum as SQLEnum
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
|
||||
import enum
|
||||
|
||||
class Action(str, enum.Enum):
|
||||
UPLOAD = "upload"
|
||||
MATCH = "match"
|
||||
QUERY = "query"
|
||||
CONSUMPTION = "consumption"
|
||||
CREATE = "create"
|
||||
DELETE = "delete"
|
||||
SOLD = "sold"
|
||||
INTERACTION = "interaction"
|
||||
COMMENT = "comment"
|
||||
CONFIG = "config"
|
||||
EMAIL = "email"
|
||||
|
||||
class Target(str, enum.Enum):
|
||||
CLIENT = "client"
|
||||
INVOICES = "invoices"
|
||||
FEED = "feed"
|
||||
EFOS = "efos"
|
||||
CREDITS = "credits"
|
||||
USERS = "users"
|
||||
EMAIL = "email"
|
||||
|
||||
|
||||
class Moves(Base):
|
||||
__tablename__ = "moves"
|
||||
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
|
||||
action_type = Column(SQLEnum(Action, name="action_type", create_type=False), nullable=False)
|
||||
target_type = Column(SQLEnum(Target, name="target_type", create_type=False), nullable=False)
|
||||
|
||||
description = Column(Text, nullable=True)
|
||||
move_metadata = Column(JSONB, nullable=True)
|
||||
|
||||
ip_address = Column(String(45), nullable=True)
|
||||
user_agent = Column(String(255), nullable=True)
|
||||
|
||||
client_id = Column(Integer, ForeignKey("clients.id"), nullable=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
is_active = Column(Boolean, nullable=False, default=True)
|
||||
|
||||
#relationships
|
||||
user = relationship("Users", foreign_keys=[user_id], back_populates="moves")
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
created_by = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now(), nullable=True)
|
||||
deleted_by = Column(Integer, ForeignKey("users.id"), nullable=True)
|
||||
|
||||
__table_args_ = (
|
||||
Index('idx_moves_client','client_id'),
|
||||
Index('idx_moves_user','user_id'),
|
||||
Index('idx_moves_action','action_type'),
|
||||
Index('idx_moves_target','target_type'),
|
||||
Index('idx_moves_created','created_at'),
|
||||
Index('idx_moves_active','is_active'),
|
||||
)
|
||||
|
||||
#Relaciones
|
||||
client = relationship("Client", foreign_keys=[client_id])
|
||||
creator = relationship("Users", foreign_keys=[created_by])
|
||||
0
app/modules/moves/repository.py
Normal file
0
app/modules/moves/repository.py
Normal file
0
app/modules/moves/route.py
Normal file
0
app/modules/moves/route.py
Normal file
0
app/modules/moves/schema.py
Normal file
0
app/modules/moves/schema.py
Normal file
Reference in New Issue
Block a user