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="{}" ) diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py index ac05cbc4f5..50da547fd8 100644 --- a/api/services/dataset_service.py +++ b/api/services/dataset_service.py @@ -986,9 +986,6 @@ class DocumentService: raise NotFound("Document not found") if document.display_status != "available": raise ValueError("Document is not available") - # update document name - if document_data.get("name"): - document.name = document_data["name"] # save process rule if document_data.get("process_rule"): process_rule = document_data["process_rule"] @@ -1065,6 +1062,10 @@ class DocumentService: document.data_source_type = document_data["data_source"]["type"] document.data_source_info = json.dumps(data_source_info) document.name = file_name + + # update document name + if document_data.get("name"): + document.name = document_data["name"] # update document to be waiting document.indexing_status = "waiting" document.completed_at = None