"""Column mixins shared by the ORM models.""" from datetime import datetime from sqlalchemy import DateTime, func from sqlalchemy.orm import Mapped, mapped_column class TimestampMixin: """Adds ``created_at`` / ``updated_at`` to a model. Timestamps are generated by the database on insert and refreshed by the ORM on update, so a row written by any client carries a server clock value. """ created_at: Mapped[datetime] = mapped_column( DateTime, nullable=False, server_default=func.now(), ) updated_at: Mapped[datetime] = mapped_column( DateTime, nullable=False, server_default=func.now(), onupdate=func.now(), )