From 7828a793eee35ada4d3fe0e91d71eceeeff7a544 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 20 Aug 2025 21:24:52 +0300 Subject: [PATCH] collection-fix --- orm/collection.py | 30 +++++++++++++++--------------- storage/schema.py | 2 +- uv.lock | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/orm/collection.py b/orm/collection.py index 0a733d26..0f9711b3 100644 --- a/orm/collection.py +++ b/orm/collection.py @@ -6,6 +6,21 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship from orm.base import BaseModel as Base +class Collection(Base): + __tablename__ = "collection" + + 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]) + + class ShoutCollection(Base): __tablename__ = "shout_collection" @@ -20,18 +35,3 @@ class ShoutCollection(Base): Index("idx_shout_collection_collection", "collection"), {"extend_existing": True}, ) - - -class Collection(Base): - __tablename__ = "collection" - - 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]) diff --git a/storage/schema.py b/storage/schema.py index f4e1b0c2..c4fde552 100644 --- a/storage/schema.py +++ b/storage/schema.py @@ -64,8 +64,8 @@ def create_all_tables() -> None: notification.Notification, # Зависит от Author notification.NotificationSeen, # Зависит от Notification collection.Collection, # Зависит от Author - collection.ShoutCollection, # Зависит от Collection и Shout invite.Invite, # Зависит от Author и Shout + collection.ShoutCollection, # Зависит от Collection и Shout ] with local_session() as session: diff --git a/uv.lock b/uv.lock index ce74f417..696ff1d8 100644 --- a/uv.lock +++ b/uv.lock @@ -399,7 +399,7 @@ wheels = [ [[package]] name = "discours-core" -version = "0.9.7" +version = "0.9.8" source = { editable = "." } dependencies = [ { name = "ariadne" },