fix(fts): regenerate AFTER triggers to force re-binding after 0003#145
Merged
Conversation
) 0003 で search_docs_code_fts table を DROP+CREATE 後も Worker が SQLITE_CORRUPT_VTAB を継続報告。trigger references の再解決のため AFTER INSERT/UPDATE/DELETE trigger を DROP + CREATE で再宣言する。 Trigger は declarative でデータを持たないため、再宣言は非破壊操作。 Body は 0001 と byte-for-byte 同一で、宣言タイミングのみが変わる。 適用は merge 後に D1 console もしくは `wrangler d1 migrations apply` で別途実行する。 Refs #135
liplus-lin-lay
commented
Apr 28, 2026
Member
Author
liplus-lin-lay
left a comment
There was a problem hiding this comment.
Self-review (auto mode required)
Migration 内容の検証
migrations/0004_fts5_triggers_regen.sqlの trigger body 3 種 (trg_search_docs_ai/trg_search_docs_ad/trg_search_docs_au) は0001_fts5_init.sqlと byte-for-byte 同一を確認済みdiffで 3 trigger 全て差分なし (AI MATCH / AD MATCH / AU MATCH)- 宣言タイミングのみ変更、SQL semantics は不変
非破壊性
- Trigger は declarative でデータを持たない
DROP TRIGGER IF EXISTS→CREATE TRIGGERは idempotentsearch_docstable およびsearch_docs_nat_fts/search_docs_code_ftsの row data には触れない
適用パス note
- merge では migration は自動適用されない
- Master もしくは AI が merge 後に別途以下のいずれかで適用する:
- D1 console で 0004 の SQL を直接実行
wrangler d1 migrations apply(Wrangler が migrations dir を順次適用)
検証パス
- 適用後の次回
:30pollDiffscron 実行でtokenizer_kind=codeの diff upsert が成功 (SQLITE_CORRUPT_VTABが消える) ことを確認 - nat_fts は元から clean なので影響観測対象外
- 失敗継続の場合は axis 2 attempt 1/3 が外れたことを意味し、autonomous loop fire の次 axis (e.g., データ層 row level の reindex / search_docs row 再作成) に進む
影響範囲
- src/*.ts は変更なし
- 0001-0003 migration files は変更なし
- 新規 SQL ファイル 1 件のみ (+57 lines)
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-rag-mcp | 883ab70 | Apr 28 2026, 05:45 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
観測
search_docs_code_fts) を merge し、D1 console で適用済みD1_ERROR: SQLITE_CORRUPT_VTABをtokenizer_kind=codeの diff upsert で継続報告 (15:30 / 16:30 / 17:30 UTCpollDiffscron)仮説
0001 で宣言された
AFTER INSERT/UPDATE/DELETEtrigger は、search_docs_code_ftsへの参照を解決した状態で compile されている。0003 で virtual table を DROP+CREATE した後、trigger が古い参照を保持しているため write が失敗している可能性がある。trigger を DROP + CREATE で再宣言することで、新しい table 実体への再 bind を強制する。変更
migrations/0004_fts5_triggers_regen.sqlを追加 (+57 lines)0001_fts5_init.sqlと byte-for-byte 同一 (検証済み)適用と検証
wrangler d1 migrations applyで 0004 を適用する:30pollDiffscron で diff upsert が成功するか確認Notes
Refs #135