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.

chore(models): remove redundant server_default from provider, tools and workflow models (#42521)

william6523584762b7
diff --git a/api/models/provider.py b/api/models/provider.py
index 1a4c9db997d..b9b68b93e27 100644
--- a/api/models/provider.py
+++ b/api/models/provider.py
@@ -55,9 +55,9 @@ class Provider(TypeBase):
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
provider_name: Mapped[str] = mapped_column(String(255), nullable=False)
provider_type: Mapped[ProviderType] = mapped_column(
- EnumText(ProviderType, length=40), nullable=False, server_default=text("'custom'"), default=ProviderType.CUSTOM
+ EnumText(ProviderType, length=40), nullable=False, default=ProviderType.CUSTOM
)
- is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"), default=False)
+ is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)
last_used: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, init=False)
credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True, default=None)
@@ -137,7 +137,7 @@ class ProviderModel(TypeBase):
model_name: Mapped[str] = mapped_column(String(255), nullable=False)
model_type: Mapped[ModelType] = mapped_column(EnumText(ModelType, length=40), nullable=False)
credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True, default=None)
- is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"), default=False)
+ is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
)
@@ -259,10 +259,8 @@ class ProviderModelSetting(TypeBase):
provider_name: Mapped[str] = mapped_column(String(255), nullable=False)
model_name: Mapped[str] = mapped_column(String(255), nullable=False)
model_type: Mapped[ModelType] = mapped_column(EnumText(ModelType, length=40), nullable=False)
- enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("true"), default=True)
- load_balancing_enabled: Mapped[bool] = mapped_column(
- sa.Boolean, nullable=False, server_default=text("false"), default=False
- )
+ enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=True)
+ load_balancing_enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
)
@@ -295,7 +293,7 @@ class LoadBalancingModelConfig(TypeBase):
credential_source_type: Mapped[CredentialSourceType | None] = mapped_column(
EnumText(CredentialSourceType, length=40), nullable=True, default=None
)
- enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("true"), default=True)
+ enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=True)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
)
@@ -324,10 +322,7 @@ class ProviderCredential(TypeBase):
encrypted_config: Mapped[str] = mapped_column(LongText, nullable=False)
user_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True, default=None)
visibility: Mapped[PermissionEnum] = mapped_column(
- EnumText(PermissionEnum, length=40),
- nullable=False,
- server_default=sa.text("'all_team_members'"),
- default=PermissionEnum.ALL_TEAM,
+ EnumText(PermissionEnum, length=40), nullable=False, default=PermissionEnum.ALL_TEAM
)
created_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
diff --git a/api/models/tools.py b/api/models/tools.py
index 900af453b9d..d42b004460a 100644
--- a/api/models/tools.py
+++ b/api/models/tools.py
@@ -108,20 +108,14 @@ class BuiltinToolProvider(TypeBase):
onupdate=func.current_timestamp(),
init=False,
)
- is_default: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.false(), default=False)
+ is_default: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)
# credential type, e.g., "api-key", "oauth2"
credential_type: Mapped[CredentialType] = mapped_column(
- EnumText(CredentialType, length=32),
- nullable=False,
- server_default=sa.text("'api-key'"),
- default=CredentialType.API_KEY,
+ EnumText(CredentialType, length=32), nullable=False, default=CredentialType.API_KEY
)
- expires_at: Mapped[int] = mapped_column(sa.BigInteger, nullable=False, server_default=sa.text("-1"), default=-1)
+ expires_at: Mapped[int] = mapped_column(sa.BigInteger, nullable=False, default=-1)
visibility: Mapped[PermissionEnum] = mapped_column(
- EnumText(PermissionEnum, length=40),
- nullable=False,
- server_default=sa.text("'all_team_members'"),
- default=PermissionEnum.ALL_TEAM,
+ EnumText(PermissionEnum, length=40), nullable=False, default=PermissionEnum.ALL_TEAM
)
@property
@@ -337,10 +331,8 @@ class MCPToolProvider(TypeBase):
onupdate=func.current_timestamp(),
init=False,
)
- timeout: Mapped[float] = mapped_column(sa.Float, nullable=False, server_default=sa.text("30"), default=30.0)
- sse_read_timeout: Mapped[float] = mapped_column(
- sa.Float, nullable=False, server_default=sa.text("300"), default=300.0
- )
+ timeout: Mapped[float] = mapped_column(sa.Float, nullable=False, default=30.0)
+ sse_read_timeout: Mapped[float] = mapped_column(sa.Float, nullable=False, default=300.0)
# encrypted headers for MCP server requests
encrypted_headers: Mapped[str | None] = mapped_column(LongText, nullable=True, default=None)
@@ -348,9 +340,7 @@ class MCPToolProvider(TypeBase):
# this provider uses. Reserved values:
# "off" — no forwarding (default; preserves pre-M2 behaviour).
# "idp_token" — forward an SSO access token minted by dify-enterprise.
- identity_mode: Mapped[str] = mapped_column(
- sa.String(32), nullable=False, server_default=sa.text("'off'"), default="off"
- )
+ identity_mode: Mapped[str] = mapped_column(sa.String(32), nullable=False, default="off")
def load_user(self, session: Session) -> Account | None:
return session.scalar(select(Account).where(Account.id == self.user_id))
diff --git a/api/models/workflow.py b/api/models/workflow.py
index 5868d78b144..2485056dae1 100644
--- a/api/models/workflow.py
+++ b/api/models/workflow.py
@@ -225,17 +225,14 @@ class Workflow(Base): # bug
app_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
type: Mapped[WorkflowType] = mapped_column(EnumText(WorkflowType, length=255), nullable=False)
kind: Mapped[WorkflowKind | None] = mapped_column(
- EnumText(WorkflowKind, length=255),
- nullable=True,
- default=WorkflowKind.STANDARD,
- server_default=sa.text("'standard'"),
+ EnumText(WorkflowKind, length=255), nullable=True, default=WorkflowKind.STANDARD
)
version: Mapped[str] = mapped_column(String(255), nullable=False)
# User-facing version number, unique and monotonically increasing within an app, displayed as `#N`.
# NULL for draft workflows and for versions published before numbering was introduced.
version_number: Mapped[int | None] = mapped_column(sa.Integer, nullable=True, default=None)
- marked_name: Mapped[str] = mapped_column(String(255), default="", server_default="")
- marked_comment: Mapped[str] = mapped_column(String(255), default="", server_default="")
+ marked_name: Mapped[str] = mapped_column(String(255), default="")
+ marked_comment: Mapped[str] = mapped_column(String(255), default="")
graph: Mapped[str] = mapped_column(LongText)
_features: Mapped[str] = mapped_column("features", LongText)
created_by: Mapped[str] = mapped_column(StringUUID, nullable=False)