Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-fts5-d1-integrity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"emdash": patch
---

Remove FTS5 integrity-check from startup verification to prevent D1 shadow table corruption
19 changes: 1 addition & 18 deletions packages/core/src/search/fts-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,7 @@ export class FTSManager {
/**
* Verify FTS index integrity and rebuild if corrupted.
*
* Checks for two corruption indicators:
* 1. Row count mismatch between content table and FTS table
* 2. FTS5 integrity-check failure (catches shadow table inconsistencies)
* Checks for row count mismatch between content table and FTS table.
*
* Returns true if the index was rebuilt, false if it was healthy.
*/
Expand Down Expand Up @@ -401,21 +399,6 @@ export class FTSManager {
return true;
}

// Check 2: FTS5 integrity check (catches shadow table corruption)
try {
await sql
.raw(`INSERT INTO "${ftsTable}"("${ftsTable}") VALUES('integrity-check')`)
.execute(this.db);
} catch {
console.warn(`FTS integrity check failed for "${collectionSlug}". Rebuilding index.`);
const fields = await this.getSearchableFields(collectionSlug);
const config = await this.getSearchConfig(collectionSlug);
if (fields.length > 0) {
await this.rebuildIndex(collectionSlug, fields, config?.weights);
}
return true;
}

return false;
}

Expand Down
Loading