add onupdate=func.current_timestamp() (#28014)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -110,7 +110,7 @@ class Account(UserMixin, TypeBase):
|
|||||||
DateTime, server_default=func.current_timestamp(), nullable=False, init=False
|
DateTime, server_default=func.current_timestamp(), nullable=False, init=False
|
||||||
)
|
)
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
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)
|
role: TenantAccountRole | None = field(default=None, init=False)
|
||||||
@@ -250,7 +250,9 @@ class Tenant(TypeBase):
|
|||||||
created_at: Mapped[datetime] = mapped_column(
|
created_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
|
||||||
)
|
)
|
||||||
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]:
|
def get_accounts(self) -> list[Account]:
|
||||||
return list(
|
return list(
|
||||||
@@ -289,7 +291,7 @@ class TenantAccountJoin(TypeBase):
|
|||||||
DateTime, server_default=func.current_timestamp(), nullable=False, init=False
|
DateTime, server_default=func.current_timestamp(), nullable=False, init=False
|
||||||
)
|
)
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
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
|
DateTime, server_default=func.current_timestamp(), nullable=False, init=False
|
||||||
)
|
)
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
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
|
DateTime, nullable=False, server_default=func.current_timestamp(), init=False
|
||||||
)
|
)
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
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()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -61,18 +61,20 @@ class Dataset(Base):
|
|||||||
created_by = mapped_column(StringUUID, nullable=False)
|
created_by = mapped_column(StringUUID, nullable=False)
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
updated_by = mapped_column(StringUUID, nullable=True)
|
||||||
updated_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
updated_at = mapped_column(
|
||||||
embedding_model = mapped_column(db.String(255), nullable=True)
|
sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()
|
||||||
embedding_model_provider = mapped_column(db.String(255), nullable=True)
|
)
|
||||||
keyword_number = mapped_column(sa.Integer, nullable=True, server_default=db.text("10"))
|
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)
|
collection_binding_id = mapped_column(StringUUID, nullable=True)
|
||||||
retrieval_model = mapped_column(JSONB, 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)
|
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)
|
pipeline_id = mapped_column(StringUUID, nullable=True)
|
||||||
chunk_structure = mapped_column(db.String(255), nullable=True)
|
chunk_structure = mapped_column(sa.String(255), nullable=True)
|
||||||
enable_api = mapped_column(sa.Boolean, nullable=False, server_default=db.text("true"))
|
enable_api = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("true"))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_documents(self):
|
def total_documents(self):
|
||||||
@@ -399,7 +401,9 @@ class Document(Base):
|
|||||||
archived_reason = mapped_column(String(255), nullable=True)
|
archived_reason = mapped_column(String(255), nullable=True)
|
||||||
archived_by = mapped_column(StringUUID, nullable=True)
|
archived_by = mapped_column(StringUUID, nullable=True)
|
||||||
archived_at: Mapped[datetime | None] = mapped_column(DateTime, 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_type = mapped_column(String(40), nullable=True)
|
||||||
doc_metadata = mapped_column(JSONB, 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"))
|
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_by = mapped_column(StringUUID, nullable=False)
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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)
|
indexing_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||||
completed_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)
|
error = mapped_column(sa.Text, nullable=True)
|
||||||
@@ -881,7 +887,7 @@ class ChildChunk(Base):
|
|||||||
)
|
)
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
updated_by = mapped_column(StringUUID, nullable=True)
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
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)
|
indexing_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||||
completed_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)
|
tenant_id = mapped_column(StringUUID, nullable=True)
|
||||||
cluster_id: Mapped[str] = mapped_column(String(255), nullable=False)
|
cluster_id: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
cluster_name: 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"))
|
active: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))
|
||||||
status = mapped_column(String(255), nullable=False, server_default=db.text("'CREATING'::character varying"))
|
status = mapped_column(String(255), nullable=False, server_default=sa.text("'CREATING'::character varying"))
|
||||||
account: Mapped[str] = mapped_column(String(255), nullable=False)
|
account: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
password: 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())
|
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_by = mapped_column(StringUUID, nullable=False)
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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]:
|
def to_dict(self) -> dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
@@ -1141,7 +1149,9 @@ class ExternalKnowledgeBindings(Base):
|
|||||||
created_by = mapped_column(StringUUID, nullable=False)
|
created_by = mapped_column(StringUUID, nullable=False)
|
||||||
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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):
|
class DatasetAutoDisableLog(Base):
|
||||||
@@ -1197,7 +1207,7 @@ class DatasetMetadata(Base):
|
|||||||
DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)")
|
DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)")
|
||||||
)
|
)
|
||||||
updated_at: Mapped[datetime] = mapped_column(
|
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)
|
created_by = mapped_column(StringUUID, nullable=False)
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
updated_by = mapped_column(StringUUID, nullable=True)
|
||||||
@@ -1224,44 +1234,48 @@ class DatasetMetadataBinding(Base):
|
|||||||
|
|
||||||
class PipelineBuiltInTemplate(Base): # type: ignore[name-defined]
|
class PipelineBuiltInTemplate(Base): # type: ignore[name-defined]
|
||||||
__tablename__ = "pipeline_built_in_templates"
|
__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()"))
|
id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))
|
||||||
name = mapped_column(db.String(255), nullable=False)
|
name = mapped_column(sa.String(255), nullable=False)
|
||||||
description = mapped_column(sa.Text, 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)
|
icon = mapped_column(sa.JSON, nullable=False)
|
||||||
yaml_content = mapped_column(sa.Text, nullable=False)
|
yaml_content = mapped_column(sa.Text, nullable=False)
|
||||||
copyright = mapped_column(db.String(255), nullable=False)
|
copyright = mapped_column(sa.String(255), nullable=False)
|
||||||
privacy_policy = mapped_column(db.String(255), nullable=False)
|
privacy_policy = mapped_column(sa.String(255), nullable=False)
|
||||||
position = mapped_column(sa.Integer, nullable=False)
|
position = mapped_column(sa.Integer, nullable=False)
|
||||||
install_count = mapped_column(sa.Integer, nullable=False, default=0)
|
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())
|
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]
|
class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]
|
||||||
__tablename__ = "pipeline_customized_templates"
|
__tablename__ = "pipeline_customized_templates"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.PrimaryKeyConstraint("id", name="pipeline_customized_template_pkey"),
|
sa.PrimaryKeyConstraint("id", name="pipeline_customized_template_pkey"),
|
||||||
db.Index("pipeline_customized_template_tenant_idx", "tenant_id"),
|
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)
|
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)
|
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)
|
icon = mapped_column(sa.JSON, nullable=False)
|
||||||
position = mapped_column(sa.Integer, nullable=False)
|
position = mapped_column(sa.Integer, nullable=False)
|
||||||
yaml_content = mapped_column(sa.Text, nullable=False)
|
yaml_content = mapped_column(sa.Text, nullable=False)
|
||||||
install_count = mapped_column(sa.Integer, nullable=False, default=0)
|
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)
|
created_by = mapped_column(StringUUID, nullable=False)
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
updated_by = mapped_column(StringUUID, nullable=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def created_user_name(self):
|
def created_user_name(self):
|
||||||
@@ -1273,19 +1287,21 @@ class PipelineCustomizedTemplate(Base): # type: ignore[name-defined]
|
|||||||
|
|
||||||
class Pipeline(Base): # type: ignore[name-defined]
|
class Pipeline(Base): # type: ignore[name-defined]
|
||||||
__tablename__ = "pipelines"
|
__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)
|
tenant_id: Mapped[str] = 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, server_default=db.text("''::character varying"))
|
description = mapped_column(sa.Text, nullable=False, server_default=sa.text("''::character varying"))
|
||||||
workflow_id = mapped_column(StringUUID, nullable=True)
|
workflow_id = mapped_column(StringUUID, nullable=True)
|
||||||
is_public = 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=db.text("false"))
|
is_published = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))
|
||||||
created_by = mapped_column(StringUUID, nullable=True)
|
created_by = mapped_column(StringUUID, nullable=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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):
|
def retrieve_dataset(self, session: Session):
|
||||||
return session.query(Dataset).where(Dataset.pipeline_id == self.id).first()
|
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):
|
class DocumentPipelineExecutionLog(Base):
|
||||||
__tablename__ = "document_pipeline_execution_logs"
|
__tablename__ = "document_pipeline_execution_logs"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.PrimaryKeyConstraint("id", name="document_pipeline_execution_log_pkey"),
|
sa.PrimaryKeyConstraint("id", name="document_pipeline_execution_log_pkey"),
|
||||||
db.Index("document_pipeline_execution_logs_document_id_idx", "document_id"),
|
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)
|
pipeline_id = mapped_column(StringUUID, nullable=False)
|
||||||
document_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_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)
|
input_data = mapped_column(sa.JSON, nullable=False)
|
||||||
created_by = mapped_column(StringUUID, nullable=True)
|
created_by = mapped_column(StringUUID, nullable=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
@@ -1311,12 +1327,14 @@ class DocumentPipelineExecutionLog(Base):
|
|||||||
|
|
||||||
class PipelineRecommendedPlugin(Base):
|
class PipelineRecommendedPlugin(Base):
|
||||||
__tablename__ = "pipeline_recommended_plugins"
|
__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)
|
plugin_id = mapped_column(sa.Text, nullable=False)
|
||||||
provider_name = mapped_column(sa.Text, nullable=False)
|
provider_name = mapped_column(sa.Text, nullable=False)
|
||||||
position = mapped_column(sa.Integer, nullable=False, default=0)
|
position = mapped_column(sa.Integer, nullable=False, default=0)
|
||||||
active = mapped_column(sa.Boolean, nullable=False, default=True)
|
active = mapped_column(sa.Boolean, nullable=False, default=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
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()
|
||||||
|
)
|
||||||
|
|||||||
@@ -95,7 +95,9 @@ class App(Base):
|
|||||||
created_by = mapped_column(StringUUID, nullable=True)
|
created_by = mapped_column(StringUUID, nullable=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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"))
|
use_icon_as_answer_icon: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -314,7 +316,9 @@ class AppModelConfig(Base):
|
|||||||
created_by = mapped_column(StringUUID, nullable=True)
|
created_by = mapped_column(StringUUID, nullable=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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)
|
opening_statement = mapped_column(sa.Text)
|
||||||
suggested_questions = mapped_column(sa.Text)
|
suggested_questions = mapped_column(sa.Text)
|
||||||
suggested_questions_after_answer = 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)
|
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"))
|
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())
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def app(self) -> App | None:
|
def app(self) -> App | None:
|
||||||
@@ -644,7 +650,9 @@ class Conversation(Base):
|
|||||||
read_account_id = mapped_column(StringUUID)
|
read_account_id = mapped_column(StringUUID)
|
||||||
dialogue_count: Mapped[int] = mapped_column(default=0)
|
dialogue_count: Mapped[int] = mapped_column(default=0)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
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")
|
messages = db.relationship("Message", backref="conversation", lazy="select", passive_deletes="all")
|
||||||
message_annotations = db.relationship(
|
message_annotations = db.relationship(
|
||||||
@@ -948,7 +956,9 @@ class Message(Base):
|
|||||||
from_end_user_id: Mapped[str | None] = mapped_column(StringUUID)
|
from_end_user_id: Mapped[str | None] = mapped_column(StringUUID)
|
||||||
from_account_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())
|
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"))
|
agent_based: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))
|
||||||
workflow_run_id: Mapped[str | None] = mapped_column(StringUUID)
|
workflow_run_id: Mapped[str | None] = mapped_column(StringUUID)
|
||||||
app_mode: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
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_end_user_id: Mapped[str | None] = mapped_column(StringUUID)
|
||||||
from_account_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())
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def from_account(self) -> Account | None:
|
def 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"))
|
hit_count: Mapped[int] = mapped_column(sa.Integer, nullable=False, server_default=sa.text("0"))
|
||||||
account_id = mapped_column(StringUUID, nullable=False)
|
account_id = mapped_column(StringUUID, nullable=False)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def account(self):
|
def account(self):
|
||||||
@@ -1443,7 +1457,9 @@ class AppAnnotationSetting(Base):
|
|||||||
created_user_id = mapped_column(StringUUID, nullable=False)
|
created_user_id = mapped_column(StringUUID, nullable=False)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_user_id = mapped_column(StringUUID, nullable=False)
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def collection_binding_detail(self):
|
def collection_binding_detail(self):
|
||||||
@@ -1471,7 +1487,9 @@ class OperationLog(Base):
|
|||||||
content = mapped_column(sa.JSON)
|
content = mapped_column(sa.JSON)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
created_ip: Mapped[str] = mapped_column(String(255), nullable=False)
|
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):
|
class DefaultEndUserSessionID(StrEnum):
|
||||||
@@ -1510,7 +1528,9 @@ class EndUser(Base, UserMixin):
|
|||||||
|
|
||||||
session_id: Mapped[str] = mapped_column()
|
session_id: Mapped[str] = mapped_column()
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
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):
|
class AppMCPServer(Base):
|
||||||
@@ -1530,7 +1550,9 @@ class AppMCPServer(Base):
|
|||||||
parameters = mapped_column(sa.Text, nullable=False)
|
parameters = mapped_column(sa.Text, nullable=False)
|
||||||
|
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_server_code(n: int) -> str:
|
def generate_server_code(n: int) -> str:
|
||||||
@@ -1576,7 +1598,9 @@ class Site(Base):
|
|||||||
created_by = mapped_column(StringUUID, nullable=True)
|
created_by = mapped_column(StringUUID, nullable=True)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
||||||
updated_by = mapped_column(StringUUID, nullable=True)
|
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))
|
code = mapped_column(String(255))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -1,62 +1,66 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy import func
|
||||||
from sqlalchemy.dialects.postgresql import JSONB
|
from sqlalchemy.dialects.postgresql import JSONB
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from .base import Base
|
from .base import Base
|
||||||
from .engine import db
|
|
||||||
from .types import StringUUID
|
from .types import StringUUID
|
||||||
|
|
||||||
|
|
||||||
class DatasourceOauthParamConfig(Base): # type: ignore[name-defined]
|
class DatasourceOauthParamConfig(Base): # type: ignore[name-defined]
|
||||||
__tablename__ = "datasource_oauth_params"
|
__tablename__ = "datasource_oauth_params"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.PrimaryKeyConstraint("id", name="datasource_oauth_config_pkey"),
|
sa.PrimaryKeyConstraint("id", name="datasource_oauth_config_pkey"),
|
||||||
db.UniqueConstraint("plugin_id", "provider", name="datasource_oauth_config_datasource_id_provider_idx"),
|
sa.UniqueConstraint("plugin_id", "provider", name="datasource_oauth_config_datasource_id_provider_idx"),
|
||||||
)
|
)
|
||||||
|
|
||||||
id = mapped_column(StringUUID, server_default=db.text("uuidv7()"))
|
id = mapped_column(StringUUID, server_default=sa.text("uuidv7()"))
|
||||||
plugin_id: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
plugin_id: Mapped[str] = mapped_column(sa.String(255), nullable=False)
|
||||||
provider: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
provider: Mapped[str] = mapped_column(sa.String(255), nullable=False)
|
||||||
system_credentials: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
system_credentials: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
||||||
|
|
||||||
|
|
||||||
class DatasourceProvider(Base):
|
class DatasourceProvider(Base):
|
||||||
__tablename__ = "datasource_providers"
|
__tablename__ = "datasource_providers"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.PrimaryKeyConstraint("id", name="datasource_provider_pkey"),
|
sa.PrimaryKeyConstraint("id", name="datasource_provider_pkey"),
|
||||||
db.UniqueConstraint("tenant_id", "plugin_id", "provider", "name", name="datasource_provider_unique_name"),
|
sa.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.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)
|
tenant_id = mapped_column(StringUUID, nullable=False)
|
||||||
name: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
name: Mapped[str] = mapped_column(sa.String(255), nullable=False)
|
||||||
provider: 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(db.String(255), nullable=False)
|
plugin_id: Mapped[str] = mapped_column(sa.String(255), nullable=False)
|
||||||
auth_type: Mapped[str] = mapped_column(db.String(255), nullable=False)
|
auth_type: Mapped[str] = mapped_column(sa.String(255), nullable=False)
|
||||||
encrypted_credentials: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
encrypted_credentials: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
||||||
avatar_url: Mapped[str] = mapped_column(sa.Text, nullable=True, default="default")
|
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")
|
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)
|
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, default=datetime.now)
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
|
sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DatasourceOauthTenantParamConfig(Base):
|
class DatasourceOauthTenantParamConfig(Base):
|
||||||
__tablename__ = "datasource_oauth_tenant_params"
|
__tablename__ = "datasource_oauth_tenant_params"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
db.PrimaryKeyConstraint("id", name="datasource_oauth_tenant_config_pkey"),
|
sa.PrimaryKeyConstraint("id", name="datasource_oauth_tenant_config_pkey"),
|
||||||
db.UniqueConstraint("tenant_id", "plugin_id", "provider", name="datasource_oauth_tenant_config_unique"),
|
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)
|
tenant_id = mapped_column(StringUUID, nullable=False)
|
||||||
provider: 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(db.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={})
|
client_params: Mapped[dict] = mapped_column(JSONB, nullable=False, default={})
|
||||||
enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)
|
enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
created_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, default=datetime.now)
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
|
sa.DateTime, nullable=False, server_default=func.current_timestamp(), onupdate=func.current_timestamp()
|
||||||
|
)
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ class Provider(Base):
|
|||||||
quota_used: Mapped[int | None] = mapped_column(sa.BigInteger, default=0)
|
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())
|
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):
|
def __repr__(self):
|
||||||
return (
|
return (
|
||||||
@@ -135,7 +137,9 @@ class ProviderModel(Base):
|
|||||||
credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True)
|
credential_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True)
|
||||||
is_valid: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("false"))
|
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())
|
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_property
|
@cached_property
|
||||||
def credential(self):
|
def credential(self):
|
||||||
@@ -170,7 +174,9 @@ class TenantDefaultModel(Base):
|
|||||||
model_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
model_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
model_type: Mapped[str] = mapped_column(String(40), 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())
|
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):
|
class TenantPreferredModelProvider(Base):
|
||||||
@@ -185,7 +191,9 @@ class TenantPreferredModelProvider(Base):
|
|||||||
provider_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
provider_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
preferred_provider_type: Mapped[str] = mapped_column(String(40), 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())
|
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):
|
class ProviderOrder(Base):
|
||||||
@@ -212,7 +220,9 @@ class ProviderOrder(Base):
|
|||||||
pay_failed_at: Mapped[datetime | None] = mapped_column(DateTime)
|
pay_failed_at: Mapped[datetime | None] = mapped_column(DateTime)
|
||||||
refunded_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())
|
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):
|
class ProviderModelSetting(Base):
|
||||||
@@ -234,7 +244,9 @@ class ProviderModelSetting(Base):
|
|||||||
enabled: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=text("true"))
|
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"))
|
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())
|
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):
|
class LoadBalancingModelConfig(Base):
|
||||||
@@ -259,7 +271,9 @@ class LoadBalancingModelConfig(Base):
|
|||||||
credential_source_type: Mapped[str | None] = mapped_column(String(40), nullable=True)
|
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"))
|
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())
|
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):
|
class ProviderCredential(Base):
|
||||||
@@ -279,7 +293,9 @@ class ProviderCredential(Base):
|
|||||||
credential_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
credential_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
encrypted_config: Mapped[str] = mapped_column(sa.Text, 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())
|
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):
|
class ProviderModelCredential(Base):
|
||||||
@@ -307,4 +323,6 @@ class ProviderModelCredential(Base):
|
|||||||
credential_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
credential_name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
encrypted_config: Mapped[str] = mapped_column(sa.Text, 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())
|
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()
|
||||||
|
)
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ class Workflow(Base):
|
|||||||
updated_at: Mapped[datetime] = mapped_column(
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
DateTime,
|
DateTime,
|
||||||
nullable=False,
|
nullable=False,
|
||||||
default=naive_utc_now(),
|
server_default=func.current_timestamp(),
|
||||||
server_onupdate=func.current_timestamp(),
|
onupdate=func.current_timestamp(),
|
||||||
)
|
)
|
||||||
_environment_variables: Mapped[str] = mapped_column(
|
_environment_variables: Mapped[str] = mapped_column(
|
||||||
"environment_variables", sa.Text, nullable=False, server_default="{}"
|
"environment_variables", sa.Text, nullable=False, server_default="{}"
|
||||||
@@ -150,7 +150,7 @@ class Workflow(Base):
|
|||||||
"conversation_variables", sa.Text, nullable=False, server_default="{}"
|
"conversation_variables", sa.Text, nullable=False, server_default="{}"
|
||||||
)
|
)
|
||||||
_rag_pipeline_variables: Mapped[str] = mapped_column(
|
_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"
|
VERSION_DRAFT = "draft"
|
||||||
|
|||||||
Reference in New Issue
Block a user