set up DB migrations

This commit is contained in:
perf3ct 2025-03-08 22:03:30 +00:00
parent b248a7a2b5
commit b97c8dd763
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
-- Add tables for vector embeddings storage and management
-- Store embeddings for notes
CREATE TABLE IF NOT EXISTS "note_embeddings" (
"embedId" TEXT NOT NULL PRIMARY KEY,
"noteId" TEXT NOT NULL,
"providerId" TEXT NOT NULL,
"modelId" TEXT NOT NULL,
"dimension" INTEGER NOT NULL,
"embedding" BLOB NOT NULL,
"version" INTEGER NOT NULL DEFAULT 1,
"dateCreated" TEXT NOT NULL,
"utcDateCreated" TEXT NOT NULL,
"dateModified" TEXT NOT NULL,
"utcDateModified" TEXT NOT NULL
);
CREATE INDEX "IDX_note_embeddings_noteId" ON "note_embeddings" ("noteId");
CREATE INDEX "IDX_note_embeddings_providerId_modelId" ON "note_embeddings" ("providerId", "modelId");
-- Table to track which notes need embedding updates
CREATE TABLE IF NOT EXISTS "embedding_queue" (
"noteId" TEXT NOT NULL PRIMARY KEY,
"operation" TEXT NOT NULL, -- CREATE, UPDATE, DELETE
"dateQueued" TEXT NOT NULL,
"utcDateQueued" TEXT NOT NULL,
"priority" INTEGER NOT NULL DEFAULT 0,
"attempts" INTEGER NOT NULL DEFAULT 0,
"lastAttempt" TEXT NULL,
"error" TEXT NULL
);
-- Table to store embedding provider configurations
CREATE TABLE IF NOT EXISTS "embedding_providers" (
"providerId" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"isEnabled" INTEGER NOT NULL DEFAULT 0,
"priority" INTEGER NOT NULL DEFAULT 0,
"config" TEXT NOT NULL, -- JSON config object
"dateCreated" TEXT NOT NULL,
"utcDateCreated" TEXT NOT NULL,
"dateModified" TEXT NOT NULL,
"utcDateModified" TEXT NOT NULL
);
-- Add default embedding provider options
INSERT INTO options (name, value, isSynced) VALUES ('embeddingAutoUpdateEnabled', 'true', 1);
INSERT INTO options (name, value, isSynced) VALUES ('embeddingUpdateInterval', '5000', 1); -- 5 seconds
INSERT INTO options (name, value, isSynced) VALUES ('embeddingBatchSize', '10', 1);
INSERT INTO options (name, value, isSynced) VALUES ('embeddingDefaultDimension', '1536', 1);