rDrama/files/classes/marsey.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

18 lines
646 B
Python

from sqlalchemy import *
from sqlalchemy.orm import Mapped, mapped_column, relationship
from files.classes.base import Base
class Marsey(Base):
__tablename__ = "marseys"
name: Mapped[str] = mapped_column(String, primary_key=True)
author_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False)
tags: Mapped[str] = mapped_column(String(length=200), nullable=False)
count: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
Index('marseys_idx2', author_id)
Index('marseys_idx3', count.desc())
Index('marseys_idx', name)
def __repr__(self):
return f"<{self.__class__.__name__}(name={self.name})>"