Skip to main content

CREATE_EMBEDDINGS_TABLE

Constant CREATE_EMBEDDINGS_TABLE 

Source
pub const CREATE_EMBEDDINGS_TABLE: &str = "
CREATE TABLE IF NOT EXISTS embeddings (
    id          INTEGER PRIMARY KEY,
    source_type TEXT NOT NULL,   -- 'symbol' | 'doc' | 'commit' | 'cluster'
    source_path TEXT NOT NULL,   -- relative file path
    source_id   INTEGER,         -- FK into symbols table where applicable
    model       TEXT NOT NULL,   -- embedding model name (triggers invalidation on change)
    last_commit TEXT,            -- git HEAD SHA when last embedded
    staleness   REAL NOT NULL DEFAULT 0.0,
    chunk_text  TEXT NOT NULL,   -- the text that was embedded (for debugging / re-use)
    embedding   BLOB NOT NULL,   -- packed f32 array, length = model dimensions
    UNIQUE(source_type, source_path, source_id)
)";
Expand description

DDL for the embeddings table.

The table is created lazily when embedding is first enabled so it does not affect repos that never turn on embeddings.enabled.

The UNIQUE constraint on (source_type, source_path, source_id) allows INSERT OR REPLACE for incremental updates without a delete-then-insert round-trip.