Skip to content

fix: auto-run database migrations on first use#5

Merged
corvid-agent merged 1 commit intomainfrom
fix/auto-migration
May 7, 2026
Merged

fix: auto-run database migrations on first use#5
corvid-agent merged 1 commit intomainfrom
fix/auto-migration

Conversation

@corvid-agent
Copy link
Copy Markdown
Collaborator

Summary

  • Replace fledge sql migrate --dir with inline CREATE TABLE IF NOT EXISTS / CREATE INDEX IF NOT EXISTS statements executed via fledge sql query
  • The previous approach relied on pluginDir/migrations being resolvable at runtime, which fails when the path contains spaces, the plugin is installed in an unexpected location, or fledge sql migrate is unavailable in older versions of fledge-plugin-sql
  • The inline approach is idempotent (IF NOT EXISTS) and runs on every cold start, eliminating the "no such table: memories" error on first use

Test plan

  • Delete .fledge/data.db and run fledge memory save --key test --value works --json -- should succeed without manual migration setup
  • Run fledge memory recall --key test --json -- should return the saved value
  • Run fledge memory list --json -- should list the saved memory
  • Run fledge memory delete --key test --json -- should delete successfully
  • Verify fledge sql schema --path .fledge/data.db shows the correct schema (memories table + indexes)
  • Verify repeated invocations don't error (IF NOT EXISTS is idempotent)

🤖 Generated with Claude Code

Replace `fledge sql migrate --dir` with inline CREATE TABLE/INDEX
statements executed via `fledge sql query`. The previous approach
relied on the migrations directory being resolvable at runtime via
`pluginDir`, which can fail when the path contains spaces, the
plugin is installed in an unexpected location, or `fledge sql migrate`
is unavailable. The inline approach uses IF NOT EXISTS so it is
idempotent and safe to re-run on every invocation.

Fixes "no such table: memories" on first save/recall/list/delete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@corvid-agent corvid-agent merged commit 3df5226 into main May 7, 2026
5 checks passed
@corvid-agent corvid-agent deleted the fix/auto-migration branch May 7, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant