Skip to main content

add_vector_column

Function add_vector_column 

Source
pub fn add_vector_column(
    conn: &Connection,
    table_name: &str,
    column_name: &str,
    config: VectorConfig,
) -> Result<()>
Expand description

Helper to add a vector column to an existing table

This adds a BLOB column and initializes it for vector search.

ยงExample

use azoth::prelude::*;
use azoth_vector::{add_vector_column, VectorConfig};
use rusqlite::Connection;

struct AddVectorToExistingTable;

impl azoth::Migration for AddVectorToExistingTable {
    fn version(&self) -> u32 { 3 }
    fn name(&self) -> &str { "add_vector_column" }

    fn up(&self, conn: &Connection) -> Result<()> {
        add_vector_column(
            conn,
            "documents",
            "embedding",
            VectorConfig::default(),
        )?;
        Ok(())
    }

    fn down(&self, conn: &Connection) -> Result<()> {
        // Note: SQLite doesn't support DROP COLUMN in older versions
        // You may need to recreate the table
        Ok(())
    }
}