消息渠道支持会话相关指令

This commit is contained in:
xintaofei
2026-04-01 10:08:20 +08:00
parent 8d8eadb994
commit 58611a6bc1
29 changed files with 1915 additions and 14 deletions

View File

@@ -0,0 +1,124 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(ChatChannelSenderContext::Table)
.if_not_exists()
.col(
ColumnDef::new(ChatChannelSenderContext::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::ChannelId)
.integer()
.not_null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::SenderId)
.string()
.not_null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::CurrentFolderId)
.integer()
.null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::CurrentAgentType)
.string()
.null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::CurrentConversationId)
.integer()
.null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::CurrentConnectionId)
.string()
.null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::AutoApprove)
.boolean()
.not_null()
.default(false),
)
.col(
ColumnDef::new(ChatChannelSenderContext::CreatedAt)
.timestamp_with_time_zone()
.not_null(),
)
.col(
ColumnDef::new(ChatChannelSenderContext::UpdatedAt)
.timestamp_with_time_zone()
.not_null(),
)
.foreign_key(
ForeignKey::create()
.name("fk_ccsc_channel_id")
.from(
ChatChannelSenderContext::Table,
ChatChannelSenderContext::ChannelId,
)
.to(ChatChannel::Table, ChatChannel::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.name("idx_ccsc_channel_sender")
.table(ChatChannelSenderContext::Table)
.col(ChatChannelSenderContext::ChannelId)
.col(ChatChannelSenderContext::SenderId)
.unique()
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(
Table::drop()
.table(ChatChannelSenderContext::Table)
.to_owned(),
)
.await
}
}
#[derive(DeriveIden)]
enum ChatChannelSenderContext {
Table,
Id,
ChannelId,
SenderId,
CurrentFolderId,
CurrentAgentType,
CurrentConversationId,
CurrentConnectionId,
AutoApprove,
CreatedAt,
UpdatedAt,
}
#[derive(DeriveIden)]
enum ChatChannel {
Table,
Id,
}

View File

@@ -6,6 +6,7 @@ mod m20260221_000001_folder_is_open;
mod m20260226_000001_agent_setting;
mod m20260227_000001_folder_parent_branch;
mod m20260330_000001_chat_channel;
mod m20260401_000001_chat_channel_sender_context;
pub struct Migrator;
#[async_trait::async_trait]
@@ -18,6 +19,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260226_000001_agent_setting::Migration),
Box::new(m20260227_000001_folder_parent_branch::Migration),
Box::new(m20260330_000001_chat_channel::Migration),
Box::new(m20260401_000001_chat_channel_sender_context::Migration),
]
}
}