included rabbitmq as broker
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import CheckConstraint, ForeignKey, Index, String, func
|
||||
from sqlalchemy import CheckConstraint, ForeignKey, Index, String, func, text
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
@@ -17,7 +18,8 @@ class Attachment(Base):
|
||||
"content_type IN ('image/png', 'image/jpeg')", name="content_type"
|
||||
),
|
||||
CheckConstraint("sha256 ~ '^[a-f0-9]{64}$'", name="sha256"),
|
||||
CheckConstraint("status = 'ready'", name="status"),
|
||||
CheckConstraint("status IN ('queued', 'processing', 'ready', 'failed')", name="status"),
|
||||
CheckConstraint("(status = 'failed' AND error_code IS NOT NULL) OR (status <> 'failed' AND error_code IS NULL)", name="error_code"),
|
||||
Index("ix_attachments_chat_id", "chat_id"),
|
||||
)
|
||||
|
||||
@@ -29,7 +31,12 @@ class Attachment(Base):
|
||||
content_type: Mapped[str] = mapped_column(String(32))
|
||||
size_bytes: Mapped[int]
|
||||
sha256: Mapped[str] = mapped_column(String(64))
|
||||
status: Mapped[str] = mapped_column(String(16), server_default="ready")
|
||||
status: Mapped[str] = mapped_column(String(16), server_default="queued")
|
||||
error_code: Mapped[str | None] = mapped_column(String(64))
|
||||
thumbnail_key: Mapped[str | None] = mapped_column(String(128))
|
||||
crop_key: Mapped[str | None] = mapped_column(String(128))
|
||||
optimized_key: Mapped[str | None] = mapped_column(String(128))
|
||||
variants: Mapped[list[dict]] = mapped_column(JSONB, default=list, server_default=text("'[]'::jsonb"))
|
||||
created_at: Mapped[datetime] = mapped_column(server_default=func.clock_timestamp())
|
||||
updated_at: Mapped[datetime] = mapped_column(server_default=func.clock_timestamp())
|
||||
|
||||
@@ -47,7 +54,7 @@ class MessageAttachment(Base):
|
||||
|
||||
|
||||
class UploadIntent(Base):
|
||||
"""Фиксируется до PUT; удаляется атомарно с публикацией ready-метаданных."""
|
||||
"""Фиксируется до PUT; удаляется атомарно с принятием queued metadata/job."""
|
||||
|
||||
__tablename__ = "upload_intents"
|
||||
__table_args__ = (Index("ix_upload_intents_created_at", "created_at"),)
|
||||
|
||||
Reference in New Issue
Block a user