CI / lint (push) Successful in 4s
Build images / sign-extension (push) Successful in 4s
CI / extension-version (push) Successful in 4s
Build images / build-agent (push) Successful in 8s
CI / frontend-build (push) Successful in 27s
CI / backend-lint-and-test (push) Successful in 33s
Build images / build-web (push) Successful in 43s
Build images / build-ml (push) Successful in 51s
CI / integration (push) Successful in 3m47s
ruff's isort runs with order-by-type, which sorts ALL_CAPS names ahead of CamelCase ones, so `JSON` belongs at the head of the list rather than between `Integer` and `String`. Two of these (backup_run.py, post.py) have been failing lint since5e1996e— I did not check the push CI after that commit, only the baseline workflow I had dispatched, so ci.yml has been red on dev across5e1996e,ed2b1adandd044e93. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017QHszn9H8VBvx5Ke8x1hvw
64 lines
2.7 KiB
Python
64 lines
2.7 KiB
Python
"""FC-3h: backup_run — operator-facing artifact record for a backup run.
|
|
|
|
One row per backup attempt (kind='db' or 'images'). Lifecycle
|
|
tracking (started_at/finished_at/duration_ms/exception text) lives
|
|
in task_run from FC-3i — this row records artifact metadata: file
|
|
paths, sizes, tag (retention protection), and restore lineage via
|
|
restored_from_id.
|
|
|
|
Status values (String, not Postgres ENUM — per
|
|
feedback_check_existing_enums):
|
|
pending — created but task hasn't started yet (rare; usually
|
|
status starts as 'running' from the task body).
|
|
running — backup task is in flight.
|
|
ok — artifact successfully written.
|
|
error — task raised; error column populated.
|
|
restoring — this row represents a restore attempt (kind = restored
|
|
kind); linked to source via restored_from_id.
|
|
restored — restore completed successfully.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import JSON, BigInteger, DateTime, ForeignKey, Index, Integer, String, Text, text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base
|
|
|
|
|
|
class BackupRun(Base):
|
|
__tablename__ = "backup_run"
|
|
|
|
|
|
__table_args__ = (
|
|
# alembic 0017: reporting indexes, never declared on the model (#3275).
|
|
Index("ix_backup_run_kind_started", "kind", text("started_at DESC")),
|
|
Index("ix_backup_run_status_finished", "status", text("finished_at DESC")),
|
|
Index("ix_backup_run_tag_partial", "tag", postgresql_where=text("tag IS NOT NULL")),
|
|
)
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
kind: Mapped[str] = mapped_column(String(16), nullable=False, index=True)
|
|
status: Mapped[str] = mapped_column(
|
|
String(16), nullable=False, default="pending", index=True,
|
|
server_default="pending",
|
|
)
|
|
tag: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
|
triggered_by: Mapped[str] = mapped_column(String(32), nullable=False)
|
|
started_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), nullable=False, index=True,
|
|
)
|
|
finished_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True, index=True,
|
|
)
|
|
sql_path: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
tar_path: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
size_bytes: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
|
|
error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
manifest: Mapped[dict] = mapped_column(
|
|
JSON, nullable=False, default=dict, server_default="{}",
|
|
)
|
|
restored_from_id: Mapped[int | None] = mapped_column(
|
|
ForeignKey("backup_run.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
)
|