-
| 
         Hi there, Imagine you have a very basic model : class Conversation(UUIDAuditBase):
    __tablename__ = "conversations"
   ...You want the  The current implementation of AuditColumns. @declarative_mixin
class AuditColumns:
    """Created/Updated At Fields Mixin."""
    created_at: Mapped[datetime.datetime] = mapped_column(
        DateTimeUTC(timezone=True),
        default=lambda: datetime.datetime.now(datetime.timezone.utc),
    )
    """Date/time of instance creation."""
    updated_at: Mapped[datetime.datetime] = mapped_column(
        DateTimeUTC(timezone=True),
        default=lambda: datetime.datetime.now(datetime.timezone.utc),
        onupdate=lambda: datetime.datetime.now(datetime.timezone.utc),
    )
    """Date/time of instance last update."""
    @validates("created_at", "updated_at")
    def validate_tz_info(self, _: str, value: datetime.datetime) -> datetime.datetime:
        if value.tzinfo is None:
            value = value.replace(tzinfo=datetime.timezone.utc)
        return valueThanks !  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
| 
         Hello, sorry for the late answer but yes you have to redefine your model with specifying  There is no other way currently (as I am aware of) Regards  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Thank you for your answers and your time! I'll have to choose between the two options, that's good!  | 
  
Beta Was this translation helpful? Give feedback.
Hello,
sorry for the late answer but yes you have to redefine your model with specifying
index=True. We decided to not add it in the default as it's adding overhead.There is no other way currently (as I am aware of)
Regards