mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-03-28 13:13:08 +00:00
fix: rebuild FTS5 index after database rebuild to prevent stale rowid refs
The FTS5 content-synced index could retain phantom rowid references from previous rebuild cycles, causing 'missing row N from content table' errors on MATCH queries. - Add explicit FTS5 rebuild command in rebuild script after all nodes saved - Add FTS5 rebuild in test beforeAll as defense-in-depth - Rebuild nodes.db with consistent FTS5 index Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,7 +43,14 @@ describe.skipIf(!dbExists)('Database Content Validation', () => {
|
||||
// Ignore NODE_DB_PATH env var which might be set to :memory: by vitest
|
||||
db = await createDatabaseAdapter(dbPath);
|
||||
repository = new NodeRepository(db);
|
||||
console.log('✅ Database found - running validation tests');
|
||||
|
||||
// Rebuild FTS5 index to ensure it is in sync with the nodes table.
|
||||
// The content-synced FTS5 index (content=nodes) can become stale if the
|
||||
// database was rebuilt without an explicit FTS5 rebuild command, leaving
|
||||
// phantom rowid references that cause "missing row" errors on MATCH queries.
|
||||
db.prepare("INSERT INTO nodes_fts(nodes_fts) VALUES('rebuild')").run();
|
||||
|
||||
console.log('Database found - running validation tests');
|
||||
});
|
||||
|
||||
describe('[CRITICAL] Database Must Have Data', () => {
|
||||
|
||||
@@ -17,6 +17,12 @@ describe('Node FTS5 Search Integration Tests', () => {
|
||||
const testDbPath = './data/nodes.db';
|
||||
db = await createDatabaseAdapter(testDbPath);
|
||||
repository = new NodeRepository(db);
|
||||
|
||||
// Rebuild FTS5 index to ensure it is in sync with the nodes table.
|
||||
// The content-synced FTS5 index (content=nodes) can become stale if the
|
||||
// database was rebuilt without an explicit FTS5 rebuild command, leaving
|
||||
// phantom rowid references that cause "missing row" errors on MATCH queries.
|
||||
db.prepare("INSERT INTO nodes_fts(nodes_fts) VALUES('rebuild')").run();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
Reference in New Issue
Block a user