|
|
@@ -1053,7 +1053,12 @@ function ensureVecTableInternal(db: Database, dimensions: number): void {
|
|
|
const hasCosine = tableInfo.sql.includes('distance_metric=cosine');
|
|
|
const existingDims = match?.[1] ? parseInt(match[1], 10) : null;
|
|
|
if (existingDims === dimensions && hasHashSeq && hasCosine) return;
|
|
|
- // Table exists but wrong schema - need to rebuild
|
|
|
+ if (existingDims !== null && existingDims !== dimensions) {
|
|
|
+ throw new Error(
|
|
|
+ `Embedding dimension mismatch: existing vectors are ${existingDims}d but the current model produces ${dimensions}d. ` +
|
|
|
+ `Run 'qmd embed -f' to re-embed with the new model.`
|
|
|
+ );
|
|
|
+ }
|
|
|
db.exec("DROP TABLE IF EXISTS vectors_vec");
|
|
|
}
|
|
|
db.exec(`CREATE VIRTUAL TABLE vectors_vec USING vec0(hash_seq TEXT PRIMARY KEY, embedding float[${dimensions}] distance_metric=cosine)`);
|