tests-passed
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import time
|
||||
from enum import Enum as Enumeration
|
||||
|
||||
from sqlalchemy import Column, ForeignKey, Integer, String
|
||||
from sqlalchemy import ForeignKey, Index, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from auth.orm import Author
|
||||
from orm.base import BaseModel as Base
|
||||
|
||||
|
||||
@@ -44,15 +46,24 @@ REACTION_KINDS = ReactionKind.__members__.keys()
|
||||
class Reaction(Base):
|
||||
__tablename__ = "reaction"
|
||||
|
||||
body = Column(String, default="", comment="Reaction Body")
|
||||
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()), index=True)
|
||||
updated_at = Column(Integer, nullable=True, comment="Updated at", index=True)
|
||||
deleted_at = Column(Integer, nullable=True, comment="Deleted at", index=True)
|
||||
deleted_by = Column(ForeignKey("author.id"), nullable=True)
|
||||
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
|
||||
quote = Column(String, nullable=True, comment="Original quoted text")
|
||||
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
|
||||
created_by = Column(ForeignKey("author.id"), nullable=False)
|
||||
kind = Column(String, nullable=False, index=True)
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
body: Mapped[str] = mapped_column(String, default="", comment="Reaction Body")
|
||||
created_at: Mapped[int] = mapped_column(Integer, nullable=False, default=lambda: int(time.time()), index=True)
|
||||
updated_at: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="Updated at", index=True)
|
||||
deleted_at: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="Deleted at", index=True)
|
||||
deleted_by: Mapped[int | None] = mapped_column(ForeignKey(Author.id), nullable=True)
|
||||
reply_to: Mapped[int | None] = mapped_column(ForeignKey("reaction.id"), nullable=True)
|
||||
quote: Mapped[str | None] = mapped_column(String, nullable=True, comment="Original quoted text")
|
||||
shout: Mapped[int] = mapped_column(ForeignKey("shout.id"), nullable=False, index=True)
|
||||
created_by: Mapped[int] = mapped_column(ForeignKey(Author.id), nullable=False)
|
||||
kind: Mapped[str] = mapped_column(String, nullable=False, index=True)
|
||||
|
||||
oid = Column(String)
|
||||
oid: Mapped[str | None] = mapped_column(String)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_reaction_created_at", "created_at"),
|
||||
Index("idx_reaction_created_by", "created_by"),
|
||||
Index("idx_reaction_shout", "shout"),
|
||||
Index("idx_reaction_kind", "kind"),
|
||||
{"extend_existing": True},
|
||||
)
|
||||
|
Reference in New Issue
Block a user