feat(db): 添加 pgvector 扩展迁移 — 知识库向量检索基础
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

Phase 3 Task 20: CREATE EXTENSION IF NOT EXISTS vector
This commit is contained in:
iven
2026-05-05 15:52:12 +08:00
parent 75a70d2e46
commit 2d2e1e191e
2 changed files with 26 additions and 0 deletions

View File

@@ -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),
]
}
}

View File

@@ -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(())
}
}