From 67ce763377b74faf9b6d1f9d45fd9b94cc6f4221 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 1 Nov 2024 18:58:54 +0800 Subject: [PATCH] fix(workflow model): ensure consistent timestamp updating (#10172) --- api/models/workflow.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/models/workflow.py b/api/models/workflow.py index 24dd10fbc5..4f0e9a5e03 100644 --- a/api/models/workflow.py +++ b/api/models/workflow.py @@ -1,6 +1,6 @@ import json from collections.abc import Mapping, Sequence -from datetime import datetime +from datetime import datetime, timezone from enum import Enum from typing import Any, Optional, Union @@ -107,7 +107,9 @@ class Workflow(db.Model): db.DateTime, nullable=False, server_default=db.text("CURRENT_TIMESTAMP(0)") ) updated_by: Mapped[Optional[str]] = mapped_column(StringUUID) - updated_at: Mapped[datetime] = mapped_column(db.DateTime, nullable=False) + updated_at: Mapped[datetime] = mapped_column( + sa.DateTime, nullable=False, default=datetime.now(tz=timezone.utc), server_onupdate=func.current_timestamp() + ) _environment_variables: Mapped[str] = mapped_column( "environment_variables", db.Text, nullable=False, server_default="{}" )