mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
Refactor: Change table chat_channel status data type. (#16061)
### What problem does this PR solve? As title. ### Type of change - [x] Refactoring
This commit is contained in:
@@ -43,8 +43,7 @@ async def create_chat_channel():
|
||||
"name": req["name"],
|
||||
"channel": req["channel"],
|
||||
"config": req["config"],
|
||||
"dialog_id": req.get("dialog_id") or None,
|
||||
"status": "1",
|
||||
"dialog_id": req.get("dialog_id") or None
|
||||
}
|
||||
ChatChannelService.insert(**channel)
|
||||
|
||||
@@ -97,7 +96,7 @@ async def update_chat_channel(channel_id):
|
||||
if dia.tenant_id != conn.tenant_id:
|
||||
return _chat_channel_auth_error(channel_id, current_user.id)
|
||||
|
||||
update_fields = {fld: req[fld] for fld in ["name", "config", "dialog_id", "status"] if fld in req}
|
||||
update_fields = {fld: req[fld] for fld in ["name", "config", "dialog_id"] if fld in req}
|
||||
if update_fields:
|
||||
ChatChannelService.update_by_id(channel_id, update_fields)
|
||||
|
||||
|
||||
@@ -1254,7 +1254,7 @@ class ChatChannel(DataBaseModel):
|
||||
channel = CharField(max_length=128, null=False, help_text="Chat channel type", index=True)
|
||||
config = JSONField(null=False, default={}, help_text="Channel credential & settings")
|
||||
dialog_id = CharField(max_length=32, null=True, default=None, help_text="connected dialog id", index=True)
|
||||
status = CharField(max_length=16, null=True, help_text="1: valid, 0: invalid", default="1", index=True)
|
||||
status = IntegerField(default=1, index=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -1777,6 +1777,7 @@ def migrate_db():
|
||||
alter_db_column_type(migrator, "document", "size", BigIntegerField(default=0, index=True))
|
||||
alter_db_column_type(migrator, "file", "size", BigIntegerField(default=0, index=True))
|
||||
alter_db_add_column(migrator, "tenant", "ocr_id", CharField(max_length=128, null=True, help_text="default ocr model ID", index=True))
|
||||
alter_db_column_type(migrator, "chat_channel", "status", IntegerField(default=1, index=True))
|
||||
# Drop both the explicit "idx_*" name from later migrations AND the
|
||||
# Peewee-auto-derived "<table-as-classname>_<col1>_<col2>" name from the
|
||||
# original TenantModelInstance definition (commit dc4b82523). Databases
|
||||
|
||||
@@ -54,7 +54,7 @@ class ChatChannelService(CommonService):
|
||||
@DB.connection_context()
|
||||
def list_active(cls):
|
||||
"""Return all enabled chat channel bots across tenants (with credentials)."""
|
||||
return list(cls.model.select().where(cls.model.status == "1"))
|
||||
return list(cls.model.select().where(cls.model.status == 1))
|
||||
|
||||
@classmethod
|
||||
@DB.connection_context()
|
||||
|
||||
Reference in New Issue
Block a user