Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
add onupdate=func.current_timestamp() (#28014)
Asuka Minato7994144df73c
diff --git a/api/models/account.py b/api/models/account.pyindex 400a2c63621..dc3f2094fd0 100644--- a/api/models/account.py+++ b/api/models/account.py@@ -110,7 +110,7 @@ class Account(UserMixin, TypeBase):DateTime, server_default=func.current_timestamp(), nullable=False, init=False)updated_at: Mapped[datetime] = mapped_column(- DateTime, server_default=func.current_timestamp(), nullable=False, init=False+ DateTime, server_default=func.current_timestamp(), nullable=False, init=False, onupdate=func.current_timestamp())role: TenantAccountRole | None = field(default=None, init=False)@@ -250,7 +250,9 @@ class Tenant(TypeBase):created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.current_timestamp(), nullable=False, init=False)- updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.current_timestamp(), init=False)+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, server_default=func.current_timestamp(), init=False, onupdate=func.current_timestamp()+ )def get_accounts(self) -> list[Account]:return list(@@ -289,7 +291,7 @@ class TenantAccountJoin(TypeBase):DateTime, server_default=func.current_timestamp(), nullable=False, init=False)updated_at: Mapped[datetime] = mapped_column(- DateTime, server_default=func.current_timestamp(), nullable=False, init=False+ DateTime, server_default=func.current_timestamp(), nullable=False, init=False, onupdate=func.current_timestamp())@@ -310,7 +312,7 @@ class AccountIntegrate(TypeBase):DateTime, server_default=func.current_timestamp(), nullable=False, init=False)updated_at: Mapped[datetime] = mapped_column(- DateTime, server_default=func.current_timestamp(), nullable=False, init=False+ DateTime, server_default=func.current_timestamp(), nullable=False, init=False, onupdate=func.current_timestamp())@@ -396,5 +398,5 @@ class TenantPluginAutoUpgradeStrategy(TypeBase):DateTime, nullable=False, server_default=func.current_timestamp(), init=False)updated_at: Mapped[datetime] = mapped_column(- DateTime, nullable=False, server_default=func.current_timestamp(), init=False+ DateTime, nullable=False, server_default=func.current_timestamp(), init=False, onupdate=func.current_timestamp())diff --git a/api/models/dataset.py b/api/models/dataset.pyindex 4a9e2688b8d..01c17fa243a 100644--- a/api/models/dataset.py+++ b/api/models/dataset.py@@ -61,18 +61,20 @@ class Dataset(Base):created_by = mapped_column(StringUUID, nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- embedding_model = mapped_column(db.String(255), nullable=True)- embedding_model_provider = mapped_column(db.String(255), nullable=True)- keyword_number = mapped_column(sa.Integer, nullable=True, server_default=db.text("10"))+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )+ embedding_model = mapped_column(sa.String(255), nullable=True)+ embedding_model_provider = mapped_column(sa.String(255), nullable=True)+ keyword_number = mapped_column(sa.Integer, nullable=True, server_default=sa.text("10"))collection_binding_id = mapped_column(StringUUID, nullable=True)retrieval_model = mapped_column(JSONB, nullable=True)- built_in_field_enabled = mapped_column(sa.Boolean, nullable=False, server_default=db.text("false"))+ built_in_field_enabled = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))icon_info = mapped_column(JSONB, nullable=True)- runtime_mode = mapped_column(db.String(255), nullable=True, server_default=db.text("'general'::character varying"))+ runtime_mode = mapped_column(sa.String(255), nullable=True, server_default=sa.text("'general'::character varying"))pipeline_id = mapped_column(StringUUID, nullable=True)- chunk_structure = mapped_column(db.String(255), nullable=True)- enable_api = mapped_column(sa.Boolean, nullable=False, server_default=db.text("true"))+ chunk_structure = mapped_column(sa.String(255), nullable=True)+ enable_api = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("true"))@propertydef total_documents(self):@@ -399,7 +401,9 @@ class Document(Base):archived_reason = mapped_column(String(255), nullable=True)archived_by = mapped_column(StringUUID, nullable=True)archived_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )doc_type = mapped_column(String(40), nullable=True)doc_metadata = mapped_column(JSONB, nullable=True)doc_form = mapped_column(String(255), nullable=False, server_default=sa.text("'text_model'::character varying"))@@ -716,7 +720,9 @@ class DocumentSegment(Base):created_by = mapped_column(StringUUID, nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )indexing_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)error = mapped_column(sa.Text, nullable=True)@@ -881,7 +887,7 @@ class ChildChunk(Base):)updated_by = mapped_column(StringUUID, nullable=True)updated_at: Mapped[datetime] = mapped_column(- DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)")+ DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)"), onupdate=func.current_timestamp())indexing_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)@@ -1036,8 +1042,8 @@ class TidbAuthBinding(Base):tenant_id = mapped_column(StringUUID, nullable=True)cluster_id: Mapped[str] = mapped_column(String(255), nullable=False)cluster_name: Mapped[str] = mapped_column(String(255), nullable=False)- active: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=db.text("false"))- status = mapped_column(String(255), nullable=False, server_default=db.text("'CREATING'::character varying"))+ active: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))+ status = mapped_column(String(255), nullable=False, server_default=sa.text("'CREATING'::character varying"))account: Mapped[str] = mapped_column(String(255), nullable=False)password: Mapped[str] = mapped_column(String(255), nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())@@ -1088,7 +1094,9 @@ class ExternalKnowledgeApis(Base):created_by = mapped_column(StringUUID, nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )def to_dict(self) -> dict[str, Any]:return {@@ -1141,7 +1149,9 @@ class ExternalKnowledgeBindings(Base):created_by = mapped_column(StringUUID, nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class DatasetAutoDisableLog(Base):@@ -1197,7 +1207,7 @@ class DatasetMetadata(Base):DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)"))updated_at: Mapped[datetime] = mapped_column(- DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)")+ DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)"), onupdate=func.current_timestamp())created_by = mapped_column(StringUUID, nullable=False)updated_by = mapped_column(StringUUID, nullable=True)@@ -1224,44 +1234,48 @@ class DatasetMetadataBinding(Base):class PipelineBuiltInTemplate(Base): # type: ignore[name-defined]__tablename__ = "pipeline_built_in_templates"- __table_args__ = (db.PrimaryKeyConstraint("id", name="pipeline_built_in_template_pkey"),)+ __table_args__ = (sa.PrimaryKeyConstraint("id", name="pipeline_built_in_template_pkey"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))- name = mapped_column(db.String(255), nullable=False)+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))+ name = mapped_column(sa.String(255), nullable=False)description = mapped_column(sa.Text, nullable=False)- chunk_structure = mapped_column(db.String(255), nullable=False)+ chunk_structure = mapped_column(sa.String(255), nullable=False)icon = mapped_column(sa.JSON, nullable=False)yaml_content = mapped_column(sa.Text, nullable=False)- copyright = mapped_column(db.String(255), nullable=False)- privacy_policy = mapped_column(db.String(255), nullable=False)+ copyright = mapped_column(sa.String(255), nullable=False)+ privacy_policy = mapped_column(sa.String(255), nullable=False)position = mapped_column(sa.Integer, nullable=False)install_count = mapped_column(sa.Integer, nullable=False, default=0)- language = mapped_column(db.String(255), nullable=False)+ language = mapped_column(sa.String(255), nullable=False)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]__tablename__ = "pipeline_customized_templates"__table_args__ = (- db.PrimaryKeyConstraint("id", name="pipeline_customized_template_pkey"),- db.Index("pipeline_customized_template_tenant_idx", "tenant_id"),+ sa.PrimaryKeyConstraint("id", name="pipeline_customized_template_pkey"),+ sa.Index("pipeline_customized_template_tenant_idx", "tenant_id"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))tenant_id = mapped_column(StringUUID, nullable=False)- name = mapped_column(db.String(255), nullable=False)+ name = mapped_column(sa.String(255), nullable=False)description = mapped_column(sa.Text, nullable=False)- chunk_structure = mapped_column(db.String(255), nullable=False)+ chunk_structure = mapped_column(sa.String(255), nullable=False)icon = mapped_column(sa.JSON, nullable=False)position = mapped_column(sa.Integer, nullable=False)yaml_content = mapped_column(sa.Text, nullable=False)install_count = mapped_column(sa.Integer, nullable=False, default=0)- language = mapped_column(db.String(255), nullable=False)+ language = mapped_column(sa.String(255), nullable=False)created_by = mapped_column(StringUUID, nullable=False)updated_by = mapped_column(StringUUID, nullable=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@propertydef created_user_name(self):@@ -1273,19 +1287,21 @@ class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]class Pipeline(Base): # type: ignore[name-defined]__tablename__ = "pipelines"- __table_args__ = (db.PrimaryKeyConstraint("id", name="pipeline_pkey"),)+ __table_args__ = (sa.PrimaryKeyConstraint("id", name="pipeline_pkey"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)- name = mapped_column(db.String(255), nullable=False)- description = mapped_column(sa.Text, nullable=False, server_default=db.text("''::character varying"))+ name = mapped_column(sa.String(255), nullable=False)+ description = mapped_column(sa.Text, nullable=False, server_default=sa.text("''::character varying"))workflow_id = mapped_column(StringUUID, nullable=True)- is_public = mapped_column(sa.Boolean, nullable=False, server_default=db.text("false"))- is_published = mapped_column(sa.Boolean, nullable=False, server_default=db.text("false"))+ is_public = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))+ is_published = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))created_by = mapped_column(StringUUID, nullable=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )def retrieve_dataset(self, session: Session):return session.query(Dataset).where(Dataset.pipeline_id == self.id).first()@@ -1294,16 +1310,16 @@ class Pipeline(Base): # type: ignore[name-defined]class DocumentPipelineExecutionLog(Base):__tablename__ = "document_pipeline_execution_logs"__table_args__ = (- db.PrimaryKeyConstraint("id", name="document_pipeline_execution_log_pkey"),- db.Index("document_pipeline_execution_logs_document_id_idx", "document_id"),+ sa.PrimaryKeyConstraint("id", name="document_pipeline_execution_log_pkey"),+ sa.Index("document_pipeline_execution_logs_document_id_idx", "document_id"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))pipeline_id = mapped_column(StringUUID, nullable=False)document_id = mapped_column(StringUUID, nullable=False)- datasource_type = mapped_column(db.String(255), nullable=False)+ datasource_type = mapped_column(sa.String(255), nullable=False)datasource_info = mapped_column(sa.Text, nullable=False)- datasource_node_id = mapped_column(db.String(255), nullable=False)+ datasource_node_id = mapped_column(sa.String(255), nullable=False)input_data = mapped_column(sa.JSON, nullable=False)created_by = mapped_column(StringUUID, nullable=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())@@ -1311,12 +1327,14 @@ class DocumentPipelineExecutionLog(Base):class PipelineRecommendedPlugin(Base):__tablename__ = "pipeline_recommended_plugins"- __table_args__ = (db.PrimaryKeyConstraint("id", name="pipeline_recommended_plugin_pkey"),)+ __table_args__ = (sa.PrimaryKeyConstraint("id", name="pipeline_recommended_plugin_pkey"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))plugin_id = mapped_column(sa.Text, nullable=False)provider_name = mapped_column(sa.Text, nullable=False)position = mapped_column(sa.Integer, nullable=False, default=0)active = mapped_column(sa.Boolean, nullable=False, default=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )diff --git a/api/models/model.py b/api/models/model.pyindex 9b7db259dd5..f698b79d323 100644--- a/api/models/model.py+++ b/api/models/model.py@@ -95,7 +95,9 @@ class App(Base):created_by = mapped_column(StringUUID, nullable=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )use_icon_as_answer_icon: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))@property@@ -314,7 +316,9 @@ class AppModelConfig(Base):created_by = mapped_column(StringUUID, nullable=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )opening_statement = mapped_column(sa.Text)suggested_questions = mapped_column(sa.Text)suggested_questions_after_answer = mapped_column(sa.Text)@@ -545,7 +549,9 @@ class RecommendedApp(Base):install_count: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)language = mapped_column(String(255), nullable=False, server_default=sa.text("'en-US'::character varying"))created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@propertydef app(self) -> App | None:@@ -644,7 +650,9 @@ class Conversation(Base):read_account_id = mapped_column(StringUUID)dialogue_count: Mapped[int] = mapped_column(default=0)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )messages = db.relationship("Message", backref="conversation", lazy="select", passive_deletes="all")message_annotations = db.relationship(@@ -948,7 +956,9 @@ class Message(Base):from_end_user_id: Mapped[str | None] = mapped_column(StringUUID)from_account_id: Mapped[str | None] = mapped_column(StringUUID)created_at: Mapped[datetime] = mapped_column(sa.DateTime, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )agent_based: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))workflow_run_id: Mapped[str | None] = mapped_column(StringUUID)app_mode: Mapped[str | None] = mapped_column(String(255), nullable=True)@@ -1296,7 +1306,9 @@ class MessageFeedback(Base):from_end_user_id: Mapped[str | None] = mapped_column(StringUUID)from_account_id: Mapped[str | None] = mapped_column(StringUUID)created_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@propertydef from_account(self) -> Account | None:@@ -1378,7 +1390,9 @@ class MessageAnnotation(Base):hit_count: Mapped[int] = mapped_column(sa.Integer, nullable=False, server_default=sa.text("0"))account_id = mapped_column(StringUUID, nullable=False)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@propertydef account(self):@@ -1443,7 +1457,9 @@ class AppAnnotationSetting(Base):created_user_id = mapped_column(StringUUID, nullable=False)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())updated_user_id = mapped_column(StringUUID, nullable=False)- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@propertydef collection_binding_detail(self):@@ -1471,7 +1487,9 @@ class OperationLog(Base):content = mapped_column(sa.JSON)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())created_ip: Mapped[str] = mapped_column(String(255), nullable=False)- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class DefaultEndUserSessionID(StrEnum):@@ -1510,7 +1528,9 @@ class EndUser(Base, UserMixin):session_id: Mapped[str] = mapped_column()created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class AppMCPServer(Base):@@ -1530,7 +1550,9 @@ class AppMCPServer(Base):parameters = mapped_column(sa.Text, nullable=False)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@staticmethoddef generate_server_code(n: int) -> str:@@ -1576,7 +1598,9 @@ class Site(Base):created_by = mapped_column(StringUUID, nullable=True)created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())updated_by = mapped_column(StringUUID, nullable=True)- updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )code = mapped_column(String(255))@propertydiff --git a/api/models/oauth.py b/api/models/oauth.pyindex ef23780dc8e..e705b3d189d 100644--- a/api/models/oauth.py+++ b/api/models/oauth.py@@ -1,62 +1,66 @@from datetime import datetimeimport sqlalchemy as sa+from sqlalchemy import funcfrom sqlalchemy.dialects.postgresql import JSONBfrom sqlalchemy.orm import Mapped, mapped_columnfrom .base import Base-from .engine import dbfrom .types import StringUUIDclass DatasourceOauthParamConfig(Base): # type: ignore[name-defined]__tablename__ = "datasource_oauth_params"__table_args__ = (- db.PrimaryKeyConstraint("id", name="datasource_oauth_config_pkey"),- db.UniqueConstraint("plugin_id", "provider", name="datasource_oauth_config_datasource_id_provider_idx"),+ sa.PrimaryKeyConstraint("id", name="datasource_oauth_config_pkey"),+ sa.UniqueConstraint("plugin_id", "provider", name="datasource_oauth_config_datasource_id_provider_idx"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))- plugin_id: Mapped[str] = mapped_column(db.String(255), nullable=False)- provider: Mapped[str] = mapped_column(db.String(255), nullable=False)+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))+ plugin_id: Mapped[str] = mapped_column(sa.String(255), nullable=False)+ provider: Mapped[str] = mapped_column(sa.String(255), nullable=False)system_credentials: Mapped[dict] = mapped_column(JSONB, nullable=False)class DatasourceProvider(Base):__tablename__ = "datasource_providers"__table_args__ = (- db.PrimaryKeyConstraint("id", name="datasource_provider_pkey"),- db.UniqueConstraint("tenant_id", "plugin_id", "provider", "name", name="datasource_provider_unique_name"),- db.Index("datasource_provider_auth_type_provider_idx", "tenant_id", "plugin_id", "provider"),+ sa.PrimaryKeyConstraint("id", name="datasource_provider_pkey"),+ sa.UniqueConstraint("tenant_id", "plugin_id", "provider", "name", name="datasource_provider_unique_name"),+ sa.Index("datasource_provider_auth_type_provider_idx", "tenant_id", "plugin_id", "provider"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))tenant_id = mapped_column(StringUUID, nullable=False)- name: Mapped[str] = mapped_column(db.String(255), nullable=False)- provider: Mapped[str] = mapped_column(db.String(255), nullable=False)- plugin_id: Mapped[str] = mapped_column(db.String(255), nullable=False)- auth_type: Mapped[str] = mapped_column(db.String(255), nullable=False)+ name: Mapped[str] = mapped_column(sa.String(255), nullable=False)+ provider: Mapped[str] = mapped_column(sa.String(255), nullable=False)+ plugin_id: Mapped[str] = mapped_column(sa.String(255), nullable=False)+ auth_type: Mapped[str] = mapped_column(sa.String(255), nullable=False)encrypted_credentials: Mapped[dict] = mapped_column(JSONB, nullable=False)avatar_url: Mapped[str] = mapped_column(sa.Text, nullable=True, default="default")- is_default: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=db.text("false"))+ is_default: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))expires_at: Mapped[int] = mapped_column(sa.Integer, nullable=False, server_default="-1")- created_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, default=datetime.now)- updated_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, default=datetime.now)+ created_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class DatasourceOauthTenantParamConfig(Base):__tablename__ = "datasource_oauth_tenant_params"__table_args__ = (- db.PrimaryKeyConstraint("id", name="datasource_oauth_tenant_config_pkey"),- db.UniqueConstraint("tenant_id", "plugin_id", "provider", name="datasource_oauth_tenant_config_unique"),+ sa.PrimaryKeyConstraint("id", name="datasource_oauth_tenant_config_pkey"),+ sa.UniqueConstraint("tenant_id", "plugin_id", "provider", name="datasource_oauth_tenant_config_unique"),)- id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))+ id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))tenant_id = mapped_column(StringUUID, nullable=False)- provider: Mapped[str] = mapped_column(db.String(255), nullable=False)- plugin_id: Mapped[str] = mapped_column(db.String(255), nullable=False)+ provider: Mapped[str] = mapped_column(sa.String(255), nullable=False)+ plugin_id: Mapped[str] = mapped_column(sa.String(255), nullable=False)client_params: Mapped[dict] = mapped_column(JSONB, nullable=False, default={})enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)- created_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, default=datetime.now)- updated_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, default=datetime.now)+ created_at: Mapped[datetime] = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )diff --git a/api/models/provider.py b/api/models/provider.pyindex f6852d49f44..e9365adb938 100644--- a/api/models/provider.py+++ b/api/models/provider.py@@ -72,7 +72,9 @@ class Provider(Base):quota_used: Mapped[int | None] = mapped_column(sa.BigInteger, default=0)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )def __repr__(self):return (@@ -135,7 +137,9 @@ class ProviderModel(Base):credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True)is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"))created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )@cached_propertydef credential(self):@@ -170,7 +174,9 @@ class TenantDefaultModel(Base):model_name: Mapped[str] = mapped_column(String(255), nullable=False)model_type: Mapped[str] = mapped_column(String(40), nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class TenantPreferredModelProvider(Base):@@ -185,7 +191,9 @@ class TenantPreferredModelProvider(Base):provider_name: Mapped[str] = mapped_column(String(255), nullable=False)preferred_provider_type: Mapped[str] = mapped_column(String(40), nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class ProviderOrder(Base):@@ -212,7 +220,9 @@ class ProviderOrder(Base):pay_failed_at: Mapped[datetime | None] = mapped_column(DateTime)refunded_at: Mapped[datetime | None] = mapped_column(DateTime)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class ProviderModelSetting(Base):@@ -234,7 +244,9 @@ class ProviderModelSetting(Base):enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("true"))load_balancing_enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"))created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class LoadBalancingModelConfig(Base):@@ -259,7 +271,9 @@ class LoadBalancingModelConfig(Base):credential_source_type: Mapped[str | None] = mapped_column(String(40), nullable=True)enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("true"))created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class ProviderCredential(Base):@@ -279,7 +293,9 @@ class ProviderCredential(Base):credential_name: Mapped[str] = mapped_column(String(255), nullable=False)encrypted_config: Mapped[str] = mapped_column(sa.Text, nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )class ProviderModelCredential(Base):@@ -307,4 +323,6 @@ class ProviderModelCredential(Base):credential_name: Mapped[str] = mapped_column(String(255), nullable=False)encrypted_config: Mapped[str] = mapped_column(sa.Text, nullable=False)created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())- updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())+ updated_at: Mapped[datetime] = mapped_column(+ DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()+ )diff --git a/api/models/workflow.py b/api/models/workflow.pyindex 1982b1bf199..18757c64aea 100644--- a/api/models/workflow.py+++ b/api/models/workflow.py@@ -140,8 +140,8 @@ class Workflow(Base):updated_at: Mapped[datetime] = mapped_column(DateTime,nullable=False,- default=naive_utc_now(),- server_onupdate=func.current_timestamp(),+ server_default=func.current_timestamp(),+ onupdate=func.current_timestamp(),)_environment_variables: Mapped[str] = mapped_column("environment_variables", sa.Text, nullable=False, server_default="{}"@@ -150,7 +150,7 @@ class Workflow(Base):"conversation_variables", sa.Text, nullable=False, server_default="{}")_rag_pipeline_variables: Mapped[str] = mapped_column(- "rag_pipeline_variables", db.Text, nullable=False, server_default="{}"+ "rag_pipeline_variables", sa.Text, nullable=False, server_default="{}")VERSION_DRAFT = "draft"