{"record":{"id":"2557a804553a4c02","repo":"thedotmack/claude-mem","slug":"fts5-table-creation-failed-search-will-use-chrom","errorCode":null,"errorMessage":"FTS5 table creation failed — search will use ChromaDB and LIKE queries","messagePattern":"FTS5 table creation failed — search will use ChromaDB and LIKE queries","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/sqlite/SessionSearch.ts","lineNumber":61,"sourceCode":"    const hasFTS = tables.some(t => t.name === 'observations_fts' || t.name === 'session_summaries_fts');\n\n    if (hasFTS) {\n      return;\n    }\n\n    if (!this.isFts5Available()) {\n      logger.warn('DB', 'FTS5 not available on this platform — skipping FTS table creation (search uses ChromaDB)');\n      return;\n    }\n\n    logger.info('DB', 'Creating FTS5 tables');\n\n    try {\n      this.createFTSTablesAndTriggers();\n      logger.info('DB', 'FTS5 tables created successfully');\n    } catch (error) {\n      this._fts5Available = false;\n      logger.warn('DB', 'FTS5 table creation failed — search will use ChromaDB and LIKE queries', {}, error instanceof Error ? error : undefined);\n    }\n  }\n\n  private isFts5Available(): boolean {\n    try {\n      this.db.run('CREATE VIRTUAL TABLE _fts5_probe USING fts5(test_column)');\n      this.db.run('DROP TABLE _fts5_probe');\n      return true;\n    } catch (error) {\n      logger.debug('DB', 'FTS5 probe failed — FTS5 unavailable on this platform', undefined, error instanceof Error ? error : new Error(String(error)));\n      return false;\n    }\n  }\n\n  private createFTSTablesAndTriggers(): void {\n    this.db.run(`\n      CREATE VIRTUAL TABLE IF NOT EXISTS observations_fts USING fts5(\n        title,","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/services/sqlite/SessionSearch.ts#L43-L79","documentation":"Logged during schema init when the FTS5 probe succeeded but createFTSTablesAndTriggers() threw while creating the real full-text tables and triggers. The service sets _fts5Available = false and degrades gracefully: text search falls back to ChromaDB vector search plus SQL LIKE queries. It is a capability warning, not data loss.","triggerScenarios":"initializeFTS() runs at startup: CREATE VIRTUAL TABLE _fts5_probe USING fts5(test_column) works, then the actual observations/sessions FTS table or trigger creation fails. Typical failures: stale FTS shadow tables left from an older schema version, a locked or read-only database file, or a corrupt database.","commonSituations":"A driver/runtime SQLite build with partial FTS5 support; a DB upgraded from an older version whose FTS table shape changed; the DB file placed on a read-only, network, or cloud-synced volume; another process holding the write lock during startup.","solutions":["Enable debug logging and restart — the error object attached to this warning names the exact SQL statement that failed","Verify FTS5 against the same file in a sqlite shell: CREATE VIRTUAL TABLE _t USING fts5(x); DROP TABLE _t;","If stale shadow tables are the cause: back up the DB, drop the *_fts tables and their _data/_idx/_content/_docsize/_config shadow tables, then restart so they are recreated","Ensure the DB file and its directory are writable and on a local filesystem","If FTS5 is genuinely unavailable on the platform, accept the fallback (ChromaDB + LIKE) or switch to a runtime with FTS5 compiled in"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import Database from 'better-sqlite3';\n\nfunction fts5Available(db: Database): boolean {\n  try {\n    db.exec('CREATE VIRTUAL TABLE _fts5_probe USING fts5(x);');\n    db.exec('DROP TABLE _fts5_probe;');\n    return true;\n  } catch {\n    return false;\n  }\n}\n\n// before relying on text search\nif (!fts5Available(db)) {\n  // plan for ChromaDB + LIKE search from the start\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a runtime whose SQLite is compiled with FTS5 and probe once at startup","Keep the DB on a local writable volume","After manual schema surgery, drop FTS shadow tables too so recreation succeeds"],"tags":["sqlite","fts5","schema-init","search-fallback"],"backgroundTag":"sqlite-fts5-unavailable","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}