created skeleton for lab 6
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Устойчивая работа и намерение публикации; один pipeline на вложение."""
|
||||
|
||||
from datetime import datetime
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from sqlalchemy import 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,
|
||||
)
|
||||
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())
|
||||
Reference in New Issue
Block a user