25 lines
891 B
Python
25 lines
891 B
Python
"""Ingest offset model for incremental sync checkpoints."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Optional
|
|
|
|
from sqlalchemy import Integer, VARCHAR, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base
|
|
from .types import JSONB
|
|
|
|
|
|
class IngestOffset(Base):
|
|
__tablename__ = "ingest_offsets"
|
|
__table_args__ = (
|
|
UniqueConstraint("tenant_id", "channel", "offset_key", name="uq_ingest_offsets_tenant_channel_key"),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
channel: Mapped[str] = mapped_column(VARCHAR(32), nullable=False, index=True)
|
|
offset_key: Mapped[str] = mapped_column(VARCHAR(128), nullable=False, index=True)
|
|
offset_value: Mapped[str] = mapped_column(VARCHAR(255), nullable=False)
|
|
payload: Mapped[Optional[Any]] = mapped_column(JSONB, nullable=True)
|