rDrama/files/classes/alts.py
justcool393 e040ed6708 Upgrade to SQLAlchemy 2.0
This has exposed an interesting amount of bugs and stopped throwing type errors every 5 seconds

It's worth noting that not all models are fully typed, that is, we
have `Mapped[Any]` in some places where a narrower type would be nice.

Upgrading to SQLA2 we don't *need* this, but it is helpful and
makes error checking reliable.
2023-08-09 02:27:55 -05:00

17 lines
611 B
Python

from sqlalchemy import *
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.orm.decl_api import DeclarativeBase, declared_attr
from files.classes.base import Base
class Alt(Base):
__tablename__ = "alts"
user1: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), primary_key=True)
user2: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), primary_key=True)
is_manual: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
Index('alts_user2_idx', user2)
def __repr__(self):
return f"<{self.__class__.__name__}(user1={self.user1}, user2={self.user2})>"