
shouldn't actually cause any issues currently since SQLAlchemy is (to my annoyance) import *ed everywhere but.
17 lines
620 B
Python
17 lines
620 B
Python
from sqlalchemy import *
|
|
from sqlalchemy.orm import relationship
|
|
from files.classes.base import Base
|
|
|
|
class UserBlock(Base):
|
|
|
|
__tablename__ = "userblocks"
|
|
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
|
target_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
|
|
|
Index('block_target_idx', target_id)
|
|
|
|
user = relationship("User", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
|
target = relationship("User", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
|
|
|
def __repr__(self):
|
|
return f"<{self.__class__.__name__}(user={self.user_id}, target={self.target_id})>"
|