26 lines
998 B
Python
26 lines
998 B
Python
"""ORM row for the global, database-backed upload policy."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy import Integer, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
from deerflow.persistence.types import BeijingDateTime, PortableJSON
|
|
|
|
|
|
class UploadPolicyRow(Base):
|
|
__tablename__ = "upload_policy"
|
|
|
|
# A named singleton keeps the schema extensible if scoped policies are
|
|
# introduced later without requiring a table redesign.
|
|
scope: Mapped[str] = mapped_column(String(64), primary_key=True, default="global")
|
|
policy_json: Mapped[dict] = mapped_column(PortableJSON(), default=dict)
|
|
revision: Mapped[int] = mapped_column(Integer, default=1, server_default="1")
|
|
updated_by: Mapped[str | None] = mapped_column(String(64))
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
BeijingDateTime(), default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC)
|
|
)
|