This commit is contained in:
k00kzaAntonovaIra
2026-11-22 19:55:50 +03:00
parent 470d9d6f1e
commit 2d10a9b788
186 changed files with 15732 additions and 425 deletions
+41
View File
@@ -0,0 +1,41 @@
"""Устойчивая работа и намерение публикации; один pipeline на вложение."""
from datetime import datetime
from uuid import UUID, uuid4
from sqlalchemy import JSON, CheckConstraint, ForeignKey, Index, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base
class AttachmentJob(Base):
__tablename__ = "attachment_jobs"
__table_args__ = (
CheckConstraint("pipeline_version = 1", name="pipeline_version"),
CheckConstraint("attempt >= 0 AND published_attempt >= 0", name="attempt"),
Index("ix_attachment_jobs_due", "next_attempt_at"),
Index("ix_attachment_jobs_lease", "lease_until"),
)
id: Mapped[UUID] = mapped_column(primary_key=True, default=uuid4)
attachment_id: Mapped[UUID] = mapped_column(
ForeignKey("attachments.id"),
unique=True,
)
trace_context: Mapped[dict | None] = mapped_column(JSON, nullable=True)
staging_key: Mapped[str | None] = mapped_column(String(128))
pipeline_version: Mapped[int] = mapped_column(server_default="1")
attempt: Mapped[int] = mapped_column(server_default="0")
cycle_start_attempt: Mapped[int] = mapped_column(server_default="0")
attempt_limit: Mapped[int | None]
last_error_permanent: Mapped[bool | None]
published_attempt: Mapped[int] = mapped_column(server_default="0")
next_attempt_at: Mapped[datetime] = mapped_column(
server_default=func.clock_timestamp()
)
lease_token: Mapped[UUID | None]
lease_until: Mapped[datetime | None]
last_error_code: Mapped[str | None] = mapped_column(String(64))
finished_at: Mapped[datetime | None]
created_at: Mapped[datetime] = mapped_column(server_default=func.clock_timestamp())