diff --git a/crates/erp-server/migration/src/lib.rs b/crates/erp-server/migration/src/lib.rs index abac88c..3e43e66 100644 --- a/crates/erp-server/migration/src/lib.rs +++ b/crates/erp-server/migration/src/lib.rs @@ -118,6 +118,7 @@ mod m20260505_000115_family_member_health_proxy; mod m20260505_000116_seed_missing_health_menus; mod m20260505_000117_create_ai_tenant_configs; mod m20260505_000118_create_ai_analysis_queue; +mod m20260505_000119_enable_pgvector; pub struct Migrator; @@ -243,6 +244,7 @@ impl MigratorTrait for Migrator { Box::new(m20260505_000116_seed_missing_health_menus::Migration), Box::new(m20260505_000117_create_ai_tenant_configs::Migration), Box::new(m20260505_000118_create_ai_analysis_queue::Migration), + Box::new(m20260505_000119_enable_pgvector::Migration), ] } } diff --git a/crates/erp-server/migration/src/m20260505_000119_enable_pgvector.rs b/crates/erp-server/migration/src/m20260505_000119_enable_pgvector.rs new file mode 100644 index 0000000..653c80e --- /dev/null +++ b/crates/erp-server/migration/src/m20260505_000119_enable_pgvector.rs @@ -0,0 +1,24 @@ +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> { + // 启用 pgvector 扩展(知识库向量检索需要) + manager + .get_connection() + .execute_unprepared("CREATE EXTENSION IF NOT EXISTS vector") + .await?; + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .get_connection() + .execute_unprepared("DROP EXTENSION IF EXISTS vector") + .await?; + Ok(()) + } +}