This commit is contained in:
@@ -6,6 +6,21 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|||||||
from orm.base import BaseModel as Base
|
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):
|
class ShoutCollection(Base):
|
||||||
__tablename__ = "shout_collection"
|
__tablename__ = "shout_collection"
|
||||||
|
|
||||||
@@ -20,18 +35,3 @@ class ShoutCollection(Base):
|
|||||||
Index("idx_shout_collection_collection", "collection"),
|
Index("idx_shout_collection_collection", "collection"),
|
||||||
{"extend_existing": True},
|
{"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])
|
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ def create_all_tables() -> None:
|
|||||||
notification.Notification, # Зависит от Author
|
notification.Notification, # Зависит от Author
|
||||||
notification.NotificationSeen, # Зависит от Notification
|
notification.NotificationSeen, # Зависит от Notification
|
||||||
collection.Collection, # Зависит от Author
|
collection.Collection, # Зависит от Author
|
||||||
collection.ShoutCollection, # Зависит от Collection и Shout
|
|
||||||
invite.Invite, # Зависит от Author и Shout
|
invite.Invite, # Зависит от Author и Shout
|
||||||
|
collection.ShoutCollection, # Зависит от Collection и Shout
|
||||||
]
|
]
|
||||||
|
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
|
|||||||
2
uv.lock
generated
2
uv.lock
generated
@@ -399,7 +399,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "discours-core"
|
name = "discours-core"
|
||||||
version = "0.9.7"
|
version = "0.9.8"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "ariadne" },
|
{ name = "ariadne" },
|
||||||
|
|||||||
Reference in New Issue
Block a user