diff --git a/src/hubgw/models/teleport_history.py b/src/hubgw/models/teleport_history.py index 7add6a9..d68da1b 100644 --- a/src/hubgw/models/teleport_history.py +++ b/src/hubgw/models/teleport_history.py @@ -1,5 +1,7 @@ """Teleport History model.""" +from __future__ import annotations + from sqlalchemy import Column, DateTime, Float, ForeignKey, String, Text from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.sql import func @@ -13,7 +15,11 @@ _LUCKPERMS_SCHEMA = APP_CONFIG.database.luckperms_schema class TeleportHistory(Base): - """Teleport History model.""" + """Teleport History model. + + This is an append-only audit log table, so it doesn't have updated_at column. + We override updated_at to None to exclude it from this model. + """ __tablename__ = "hub_teleport_history" __table_args__ = {"schema": _HUB_SCHEMA} @@ -35,8 +41,11 @@ class TeleportHistory(Base): to_x = Column(Float, nullable=False) # DOUBLE PRECISION to_y = Column(Float, nullable=False) # DOUBLE PRECISION to_z = Column(Float, nullable=False) # DOUBLE PRECISION - tp_type = Column(String(50), nullable=False) + tp_type = Column(String(50), nullable=False, index=True) target_name = Column(String(255)) created_at = Column( - DateTime(timezone=True), server_default=func.now(), nullable=False + DateTime(timezone=True), server_default=func.now(), nullable=False, index=True ) + + # Override updated_at from Base to exclude it + updated_at = None diff --git a/src/hubgw/schemas/teleport_history.py b/src/hubgw/schemas/teleport_history.py index c814d85..70be14d 100644 --- a/src/hubgw/schemas/teleport_history.py +++ b/src/hubgw/schemas/teleport_history.py @@ -6,7 +6,7 @@ from uuid import UUID from pydantic import BaseModel -from hubgw.schemas.common import BaseSchema, PaginationParams +from hubgw.schemas.common import PaginationParams class TeleportHistoryBase(BaseModel): @@ -30,8 +30,11 @@ class TeleportHistoryCreate(TeleportHistoryBase): player_uuid: str -class TeleportHistory(TeleportHistoryBase, BaseSchema): - """Teleport history schema.""" +class TeleportHistory(TeleportHistoryBase): + """Teleport history response schema. + + This is an append-only audit log, so it only has created_at (no updated_at). + """ id: UUID player_uuid: str