fix s3 storage

This commit is contained in:
2026-11-04 22:00:11 +03:00
parent 7576ee8c83
commit 5ceab4825e
10 changed files with 274 additions and 108 deletions
+9 -3
View File
@@ -13,7 +13,9 @@ class Attachment(Base):
__tablename__ = "attachments"
__table_args__ = (
CheckConstraint("size_bytes BETWEEN 1 AND 10485760", name="size_bytes"),
CheckConstraint("content_type IN ('image/png', 'image/jpeg')", name="content_type"),
CheckConstraint(
"content_type IN ('image/png', 'image/jpeg')", name="content_type"
),
CheckConstraint("sha256 ~ '^[a-f0-9]{64}$'", name="sha256"),
CheckConstraint("status = 'ready'", name="status"),
Index("ix_attachments_chat_id", "chat_id"),
@@ -35,8 +37,12 @@ class Attachment(Base):
class MessageAttachment(Base):
__tablename__ = "message_attachments"
message_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("messages.id", ondelete="CASCADE"), primary_key=True)
attachment_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("attachments.id"), primary_key=True)
message_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("messages.id", ondelete="CASCADE"), primary_key=True
)
attachment_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("attachments.id"), primary_key=True
)
position: Mapped[int]