tests-passed

This commit is contained in:
2025-07-31 18:55:59 +03:00
parent b7abb8d8a1
commit e7230ba63c
126 changed files with 8326 additions and 3207 deletions

View File

@@ -1,7 +1,7 @@
import time
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from sqlalchemy import ForeignKey, Index, Integer, PrimaryKeyConstraint, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from orm.base import BaseModel as Base
@@ -9,19 +9,29 @@ from orm.base import BaseModel as Base
class ShoutCollection(Base):
__tablename__ = "shout_collection"
shout = Column(ForeignKey("shout.id"), primary_key=True)
collection = Column(ForeignKey("collection.id"), primary_key=True)
shout: Mapped[int] = mapped_column(ForeignKey("shout.id"))
collection: Mapped[int] = mapped_column(ForeignKey("collection.id"))
created_at: Mapped[int] = mapped_column(Integer, default=lambda: int(time.time()))
created_by: Mapped[int] = mapped_column(ForeignKey("author.id"), comment="Created By")
__table_args__ = (
PrimaryKeyConstraint(shout, collection),
Index("idx_shout_collection_shout", "shout"),
Index("idx_shout_collection_collection", "collection"),
{"extend_existing": True},
)
class Collection(Base):
__tablename__ = "collection"
slug = Column(String, unique=True)
title = Column(String, nullable=False, comment="Title")
body = Column(String, nullable=True, comment="Body")
pic = Column(String, nullable=True, comment="Picture")
created_at = Column(Integer, default=lambda: int(time.time()))
created_by = Column(ForeignKey("author.id"), comment="Created By")
published_at = Column(Integer, default=lambda: int(time.time()))
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
slug: Mapped[str] = mapped_column(String, unique=True)
title: Mapped[str] = mapped_column(String, nullable=False, comment="Title")
body: Mapped[str | None] = mapped_column(String, nullable=True, comment="Body")
pic: Mapped[str | None] = mapped_column(String, nullable=True, comment="Picture")
created_at: Mapped[int] = mapped_column(Integer, default=lambda: int(time.time()))
created_by: Mapped[int] = mapped_column(ForeignKey("author.id"), comment="Created By")
published_at: Mapped[int] = mapped_column(Integer, default=lambda: int(time.time()))
created_by_author = relationship("Author", foreign_keys=[created_by])