MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / recreateFtsTriggers

Method recreateFtsTriggers

src/db/index.ts:339–353  ·  view source on GitHub ↗

* Recreate the FTS sync triggers from schema.sql — extracted from the file * rather than duplicated here so the DDL cannot drift from the schema. * (Re-execing the whole schema is not an option: it contains data INSERTs * that are not idempotent, e.g. schema_versions.)

()

Source from the content-addressed store, hash-verified

337 * that are not idempotent, e.g. schema_versions.)
338 */
339 private recreateFtsTriggers(): void {
340 const schemaPath = path.join(__dirname, 'schema.sql');
341 const schema = fs.readFileSync(schemaPath, 'utf-8');
342 const triggerDdls = schema.match(
343 /CREATE TRIGGER IF NOT EXISTS nodes_a[idu]\b[\s\S]*?END;/g
344 );
345 if (!triggerDdls || triggerDdls.length !== DatabaseConnection.FTS_TRIGGER_NAMES.length) {
346 throw new Error(
347 `schema.sql: expected ${DatabaseConnection.FTS_TRIGGER_NAMES.length} nodes FTS triggers, found ${triggerDdls?.length ?? 0}`
348 );
349 }
350 for (const ddl of triggerDdls) {
351 this.db.exec(ddl);
352 }
353 }
354
355 /**
356 * Get the underlying database instance

Callers 1

endBulkNodeLoadMethod · 0.95

Calls 2

execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected