feat: persist dev backend SQLite between runs#66
Merged
Conversation
The dev harness configured the Backstage backend DB as better-sqlite3 with connection ':memory:', so the catalog and search index were rebuilt from scratch on every restart. Point better-sqlite3 at a directory (../../.data, resolved from the backend cwd packages/backend to the repo root) so Backstage writes one persistent <pluginId>.sqlite file per plugin and reuses them across restarts. Gitignore the .data directory. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
The dev harness configured the Backstage backend DB as
better-sqlite3withconnection: ':memory:', so the catalog and search index were rebuilt from scratch on every restart.(The rw engine's own SQLite — the comments store — was a red herring: it's already persisted at
.rw/comments/sqlite.dband the backend plugin doesn't open it.)Change
Point
better-sqlite3at a directory instead of:memory:, so Backstage writes one persistent<pluginId>.sqlitefile per plugin (catalog.sqlite,search.sqlite, …) and reuses them across restarts.app-config.yaml—connection: { directory: ../../.data }. The path is resolved relative to the backend process cwd (packages/backend, sincebackstage-clidoes nochdir), so../../lands at the repo root..gitignore— ignore/.data/.README.md— documentyarn devand the new.data/persistence (delete it to reset).Verification
@backstage/backend-defaultssource that the multi-plugin backend requiresconnection.directory(a basefilenameto a real file throws), auto-creates the dir, and writes/reuses one file per plugin.packages/backend,../../.dataresolves to repo-root.data/.🤖 Generated with Claude Code