From 6570e844ab7351d7d9bc67f5e2ae5f2caa865d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBeeRad=E2=80=9D?= Date: Sat, 11 Apr 2026 21:54:21 +1000 Subject: [PATCH] fix: stop os startup from rewriting nodes fts --- src/services/database/sqlite-client.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/services/database/sqlite-client.ts b/src/services/database/sqlite-client.ts index d3a80d0..11ab8fb 100644 --- a/src/services/database/sqlite-client.ts +++ b/src/services/database/sqlite-client.ts @@ -1073,21 +1073,16 @@ class SQLiteClient { } catch {} } - // Recreate nodes_fts to index title + source + description + // Only create nodes_fts when it does not exist yet. + // Do not rewrite existing FTS tables on startup in the OS app. try { const ftsCheck = this.db.prepare("SELECT sql FROM sqlite_master WHERE name='nodes_fts'").get() as { sql?: string } | undefined; - const needsRebuild = !ftsCheck?.sql || !ftsCheck.sql.includes('source') || ftsCheck.sql.includes('notes') || ftsCheck.sql.includes('content'); - if (needsRebuild) { - this.db.exec('DROP TABLE IF EXISTS nodes_fts;'); + if (!ftsCheck?.sql) { this.db.exec("CREATE VIRTUAL TABLE nodes_fts USING fts5(title, source, description, content='nodes', content_rowid='id');"); this.db.exec("INSERT INTO nodes_fts(nodes_fts) VALUES('rebuild');"); } } catch (ftsErr) { - if (this.isSqliteCorruptError(ftsErr)) { - this.disableNodesFts('existing nodes_fts is corrupt and could not be rebuilt', ftsErr); - } else { - console.warn('Failed to rebuild nodes_fts:', ftsErr); - } + console.warn('Failed to initialize nodes_fts:', ftsErr); } } catch (schemaErr) { console.warn('Final schema pass migration error:', schemaErr);