文件
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

33 行
1.3 KiB
TypeScript

import { SqlQuery } from '../types';
// Storage for the AI embeddings index. Two tables:
//
// - `note_embeddings_meta` holds the per-chunk metadata. It is a regular table
// so the metadata (chunk text, source note ID, model identifier) can be
// inspected and managed even on platforms where the sqlite-vec extension
// isn't available.
//
// - `note_embeddings_vec` is the sqlite-vec virtual table holding the actual
// vectors. It is created lazily by the embeddings code when sqlite-vec is
// available, because virtual-table syntax differs by extension version and
// trying to create it unconditionally would break startup on platforms
// without the prebuilt.
//
// Neither table is synced — embeddings are large, model-specific, and easily
// re-derivable on demand.
export default (): (SqlQuery|string)[] => {
return [
`CREATE TABLE IF NOT EXISTS note_embeddings_meta (
id INTEGER PRIMARY KEY AUTOINCREMENT,
note_id TEXT NOT NULL,
chunk_index INTEGER NOT NULL,
model_id TEXT NOT NULL,
chunk_text TEXT NOT NULL,
created_time INT NOT NULL DEFAULT 0
)`,
'CREATE INDEX IF NOT EXISTS note_embeddings_meta_note_id ON note_embeddings_meta(note_id)',
'CREATE UNIQUE INDEX IF NOT EXISTS note_embeddings_meta_note_chunk ON note_embeddings_meta(note_id, chunk_index)',
];
};