da9c19b2dc
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""MigrationRun — tracks each FC-5 migration invocation (backup/gs/ir/etc).
|
|
|
|
kind/status are String(32) not Postgres ENUM so adding kinds later
|
|
doesn't need a schema migration. The API layer validates values.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
import sqlalchemy as sa
|
|
from sqlalchemy import Boolean, DateTime, Integer, String, Text, func
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base
|
|
|
|
|
|
class MigrationRun(Base):
|
|
__tablename__ = "migration_run"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
kind: Mapped[str] = mapped_column(String(32), nullable=False, index=True)
|
|
status: Mapped[str] = mapped_column(String(32), nullable=False, index=True)
|
|
dry_run: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
started_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), nullable=False, server_default=func.now(),
|
|
)
|
|
finished_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True,
|
|
)
|
|
counts: Mapped[dict] = mapped_column(
|
|
JSONB, nullable=False, default=dict, server_default=sa.text("'{}'::jsonb"),
|
|
)
|
|
error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
metadata_: Mapped[dict] = mapped_column(
|
|
"metadata", JSONB, nullable=False, default=dict,
|
|
server_default=sa.text("'{}'::jsonb"),
|
|
)
|