Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix: flask db check fails due to nullable mismatch between migrations and models (#30474)

Toshiki Sugimizuf57aa08a3fff
diff --git a/api/models/model.py b/api/models/model.py
index b6f2751a72d..52e409d85a7 100644
--- a/api/models/model.py
+++ b/api/models/model.py
@@ -1534,7 +1534,7 @@ class OperationLog(TypeBase):
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
account_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
action: Mapped[str] = mapped_column(String(255), nullable=False)
- content: Mapped[Any] = mapped_column(sa.JSON)
+ content: Mapped[Any | None] = mapped_column(sa.JSON, nullable=True)
created_at: Mapped[datetime] = mapped_column(
sa.DateTime, nullable=False, server_default=func.current_timestamp(), init=False
)
diff --git a/api/models/provider.py b/api/models/provider.py
index 2afd8c53296..d68d56d32af 100644
--- a/api/models/provider.py
+++ b/api/models/provider.py
@@ -76,7 +76,7 @@ class Provider(TypeBase):
quota_type: Mapped[str | None] = mapped_column(String(40), nullable=True, server_default=text("''"), default="")
quota_limit: Mapped[int | None] = mapped_column(sa.BigInteger, nullable=True, default=None)
- quota_used: Mapped[int] = mapped_column(sa.BigInteger, nullable=False, default=0)
+ quota_used: Mapped[int | None] = mapped_column(sa.BigInteger, nullable=True, default=0)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
diff --git a/api/models/trigger.py b/api/models/trigger.py
index 87e2a5ccfcd..209345eb846 100644
--- a/api/models/trigger.py
+++ b/api/models/trigger.py
@@ -415,7 +415,7 @@ class AppTrigger(TypeBase):
node_id: Mapped[str | None] = mapped_column(String(64), nullable=False)
trigger_type: Mapped[str] = mapped_column(EnumText(AppTriggerType, length=50), nullable=False)
title: Mapped[str] = mapped_column(String(255), nullable=False)
- provider_name: Mapped[str] = mapped_column(String(255), server_default="", default="") # why it is nullable?
+ provider_name: Mapped[str | None] = mapped_column(String(255), nullable=True, server_default="", default="")
status: Mapped[str] = mapped_column(
EnumText(AppTriggerStatus, length=50), nullable=False, default=AppTriggerStatus.ENABLED
)