Skip to content

fix(schema): wire up FTS5 lifecycle in SchemaRegistry#407

Open
Pouf5 wants to merge 2 commits intoemdash-cms:mainfrom
Pouf5:fix-collections-fts5
Open

fix(schema): wire up FTS5 lifecycle in SchemaRegistry#407
Pouf5 wants to merge 2 commits intoemdash-cms:mainfrom
Pouf5:fix-collections-fts5

Conversation

@Pouf5
Copy link
Copy Markdown
Contributor

@Pouf5 Pouf5 commented Apr 9, 2026

What does this PR do?

  • rebuildSearchIndex now gates on supports.includes("search") instead of search_config.enabled, making supports the single source of truth
  • createField calls rebuildSearchIndex when input.searchable is true
  • deleteField drops FTS triggers before ALTER TABLE DROP COLUMN (SQLite validates triggers on column drop), then rebuilds/drops FTS as needed
  • deleteCollection drops the FTS virtual table before dropping the content table to avoid orphaned tables
  • updateCollection toggles FTS on/off when search is added/removed from the supports array

Adds 11 failing tests covering all four bugs before implementing fixes.

Type of change

  • Bug fix
  • Feature (requires approved Discussion)
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm --silent lint:json | jq '.diagnostics | length' returns 0
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

2 pre-existing warnings in unrelated files (vite-config.ts:291, vitest.config.ts:7); git diff main on both is empty

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

- rebuildSearchIndex now gates on supports.includes("search") instead
  of search_config.enabled, making supports the single source of truth
- createField calls rebuildSearchIndex when input.searchable is true
- deleteField drops FTS triggers before ALTER TABLE DROP COLUMN (SQLite
  validates triggers on column drop), then rebuilds/drops FTS as needed
- deleteCollection drops the FTS virtual table before dropping the
  content table to avoid orphaned tables
- updateCollection toggles FTS on/off when search is added/removed
  from the supports array

Adds 11 failing tests covering all four bugs before implementing fixes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: 3e387d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-ai-moderation Patch
@emdash-cms/plugin-atproto Patch
@emdash-cms/plugin-audit-log Patch
@emdash-cms/plugin-color Patch
@emdash-cms/plugin-embeds Patch
@emdash-cms/plugin-forms Patch
@emdash-cms/plugin-webhook-notifier Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 9, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@407

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@407

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@407

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@407

emdash

npm i https://pkg.pr.new/emdash@407

create-emdash

npm i https://pkg.pr.new/create-emdash@407

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@407

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@407

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@407

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@407

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@407

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@407

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@407

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@407

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@407

commit: ef197c6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant