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.

refactor: migrate RecommendedApp to TypeBase (#34808)

sxxtonyea9f74b58117
diff --git a/api/models/model.py b/api/models/model.py
index 0ea2259a194..365564d7845 100644
--- a/api/models/model.py
+++ b/api/models/model.py
@@ -838,7 +838,7 @@ class AppModelConfig(TypeBase):
return self
-class RecommendedApp(Base): # bug
+class RecommendedApp(TypeBase):
__tablename__ = "recommended_apps"
__table_args__ = (
sa.PrimaryKeyConstraint("id", name="recommended_app_pkey"),
@@ -846,20 +846,37 @@ class RecommendedApp(Base): # bug
sa.Index("recommended_app_is_listed_idx", "is_listed", "language"),
)
- id = mapped_column(StringUUID, primary_key=True, default=lambda: str(uuid4()))
- app_id = mapped_column(StringUUID, nullable=False)
- description = mapped_column(sa.JSON, nullable=False)
+ id: Mapped[str] = mapped_column(
+ StringUUID,
+ primary_key=True,
+ insert_default=lambda: str(uuid4()),
+ default_factory=lambda: str(uuid4()),
+ init=False,
+ )
+ app_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
+ description: Mapped[Any] = mapped_column(sa.JSON, nullable=False)
copyright: Mapped[str] = mapped_column(String(255), nullable=False)
privacy_policy: Mapped[str] = mapped_column(String(255), nullable=False)
- custom_disclaimer: Mapped[str] = mapped_column(LongText, default="")
category: Mapped[str] = mapped_column(String(255), nullable=False)
+ custom_disclaimer: Mapped[str] = mapped_column(LongText, default="")
position: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)
is_listed: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=True)
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'"))
- 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(), onupdate=func.current_timestamp()
+ language: Mapped[str] = mapped_column(
+ String(255),
+ nullable=False,
+ server_default=sa.text("'en-US'"),
+ default="en-US",
+ )
+ created_at: Mapped[datetime] = mapped_column(
+ sa.DateTime, nullable=False, server_default=func.current_timestamp(), init=False
+ )
+ updated_at: Mapped[datetime] = mapped_column(
+ sa.DateTime,
+ nullable=False,
+ server_default=func.current_timestamp(),
+ onupdate=func.current_timestamp(),
+ init=False,
)
@property