
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.
21 lines
783 B
Python
21 lines
783 B
Python
from sqlalchemy import *
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from files.classes.base import Base
|
|
|
|
|
|
class SaveRelationship(Base):
|
|
__tablename__ = "save_relationship"
|
|
|
|
user_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), primary_key=True)
|
|
submission_id: Mapped[int] = mapped_column(Integer, ForeignKey("submissions.id"), primary_key=True)
|
|
|
|
Index('fki_save_relationship_submission_fkey', submission_id)
|
|
|
|
|
|
class CommentSaveRelationship(Base):
|
|
__tablename__ = "comment_save_relationship"
|
|
|
|
user_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), primary_key=True)
|
|
comment_id: Mapped[int] = mapped_column(Integer, ForeignKey("comments.id"), primary_key=True)
|
|
|
|
Index('fki_comment_save_relationship_comment_fkey', comment_id)
|