fix(workflow model): ensure consistent timestamp updating (#10172)

This commit is contained in:
-LAN- 2024-11-01 18:58:54 +08:00 committed by Yeuoly
parent d1c480a7d8
commit 0d5c0b4fe4
No known key found for this signature in database
GPG Key ID: A66E7E320FB19F61

View File

@ -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 TYPE_CHECKING, Any, Optional, Union
@ -111,7 +111,9 @@ class Workflow(Base):
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="{}"
)