21 lines
941 B
Python
21 lines
941 B
Python
"""Table sync_log — Journal de synchronisation."""
|
|
import uuid
|
|
from datetime import datetime, timezone
|
|
from sqlalchemy import String, BigInteger, DateTime, ForeignKey, JSON, Enum as SAEnum
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from app.core.database import Base
|
|
|
|
|
|
class SyncLog(Base):
|
|
__tablename__ = "sync_log"
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
groupe_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("groupes.id"))
|
|
table_name: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
record_id: Mapped[uuid.UUID] = mapped_column(nullable=False)
|
|
action: Mapped[str] = mapped_column(
|
|
SAEnum("insert", "update", "delete", name="sync_action"),
|
|
nullable=False,
|
|
)
|
|
timestamp: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
|
|
data: Mapped[dict | None] = mapped_column(JSON)
|