mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 01:26:33 +08:00
refactor: port TidbAuthBinding( (#31006)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
5008f5e89b
commit
f7f9a08fa5
@ -1149,7 +1149,7 @@ class DatasetCollectionBinding(TypeBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TidbAuthBinding(Base):
|
class TidbAuthBinding(TypeBase):
|
||||||
__tablename__ = "tidb_auth_bindings"
|
__tablename__ = "tidb_auth_bindings"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
sa.PrimaryKeyConstraint("id", name="tidb_auth_bindings_pkey"),
|
sa.PrimaryKeyConstraint("id", name="tidb_auth_bindings_pkey"),
|
||||||
@ -1158,7 +1158,13 @@ class TidbAuthBinding(Base):
|
|||||||
sa.Index("tidb_auth_bindings_created_at_idx", "created_at"),
|
sa.Index("tidb_auth_bindings_created_at_idx", "created_at"),
|
||||||
sa.Index("tidb_auth_bindings_status_idx", "status"),
|
sa.Index("tidb_auth_bindings_status_idx", "status"),
|
||||||
)
|
)
|
||||||
id: Mapped[str] = mapped_column(StringUUID, primary_key=True, default=lambda: str(uuid4()))
|
id: Mapped[str] = mapped_column(
|
||||||
|
StringUUID,
|
||||||
|
primary_key=True,
|
||||||
|
insert_default=lambda: str(uuid4()),
|
||||||
|
default_factory=lambda: str(uuid4()),
|
||||||
|
init=False,
|
||||||
|
)
|
||||||
tenant_id: Mapped[str | None] = mapped_column(StringUUID, nullable=True)
|
tenant_id: Mapped[str | None] = 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)
|
||||||
@ -1166,7 +1172,9 @@ class TidbAuthBinding(Base):
|
|||||||
status: Mapped[str] = mapped_column(sa.String(255), nullable=False, server_default=sa.text("'CREATING'"))
|
status: Mapped[str] = mapped_column(sa.String(255), nullable=False, server_default=sa.text("'CREATING'"))
|
||||||
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(), init=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Whitelist(TypeBase):
|
class Whitelist(TypeBase):
|
||||||
|
|||||||
@ -50,10 +50,13 @@ def create_clusters(batch_size):
|
|||||||
)
|
)
|
||||||
for new_cluster in new_clusters:
|
for new_cluster in new_clusters:
|
||||||
tidb_auth_binding = TidbAuthBinding(
|
tidb_auth_binding = TidbAuthBinding(
|
||||||
|
tenant_id=None,
|
||||||
cluster_id=new_cluster["cluster_id"],
|
cluster_id=new_cluster["cluster_id"],
|
||||||
cluster_name=new_cluster["cluster_name"],
|
cluster_name=new_cluster["cluster_name"],
|
||||||
account=new_cluster["account"],
|
account=new_cluster["account"],
|
||||||
password=new_cluster["password"],
|
password=new_cluster["password"],
|
||||||
|
active=False,
|
||||||
|
status="CREATING",
|
||||||
)
|
)
|
||||||
db.session.add(tidb_auth_binding)
|
db.session.add(tidb_auth_binding)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user