lab5: асинхронный воркер, брокер сообщений

This commit is contained in:
2026-11-20 18:44:04 +03:00
parent 276dbdad8a
commit 35753ff11d
88 changed files with 5726 additions and 53 deletions
+48
View File
@@ -0,0 +1,48 @@
import uuid
from datetime import datetime
from sqlalchemy import String, Integer, ForeignKey, DateTime, func
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base
class Attachment(Base):
__tablename__ = "attachments"
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
object_key: Mapped[str] = mapped_column(String, unique=True)
filename: Mapped[str] = mapped_column(String)
mime_type: Mapped[str] = mapped_column(String)
size_bytes: Mapped[int] = mapped_column(Integer)
chat_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("chats.id"))
user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"))
sha256: Mapped[str] = mapped_column(String, nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now()
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
onupdate=func.now()
)
status: Mapped[str] = mapped_column(String, default="queued")
error_code: Mapped[str] = mapped_column(String, nullable=True)
lease_expires_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True),
nullable=True
)
thumbnail_key: Mapped[str] = mapped_column(String, nullable=True)
thumbnail_sha256: Mapped[str] = mapped_column(String, nullable=True)
thumbnail_size_bytes: Mapped[int] = mapped_column(Integer, nullable=True)
thumbnail_width: Mapped[int] = mapped_column(Integer, nullable=True)
thumbnail_height: Mapped[int] = mapped_column(Integer, nullable=True)
crop_key: Mapped[str] = mapped_column(String, nullable=True)
webp_key: Mapped[str] = mapped_column(String, nullable=True)