Repository navigation
refactor(storage): split LocalDb into a schema and per-area repositories (#1502) - #1721
Merged
Merged
Conversation
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.
Closes #1502
local_db.dartwent from 1396 to 361 lines.LocalDb.instancekeeps every public method with the same signature, so none of the ~190 importers change; it now delegates.local_db_schema.dartLocalDbSchema:version,onCreate,onUpgrade(v1 to v13), the open pragmas, the profile idlocal_db_models.dartConnectionRow,SqlQueryHistoryEntry,MutationAuditEntry,McpActivityEntry,MutationAuditSourceand the caps (re-exported fromlocal_db.dart)folder_repository.dartsql_query_history_repository.dartactivity_log_repository.dartapp_settings_repository.dartconnection_repository.dartEach repository takes the open-database function, so it runs on any
Database, an in-memory one included. Method bodies were moved as they were.LocalDbkeeps the open/close lifecycle, the file operations (path, backup, reset, WAL cleanup) andbackupBeforeUpdate.Tests:
local_db_schema_test.dartcreates a database fresh, upgrades a hand-built version 1 database (connections and folders survive) and a version 11 one (refusal column, ER layouts table), and checks the pragmas and the profile id.storage_repositories_test.dartruns four repositories on an in-memory database withoutLocalDb. The existing storage, MCP, database, connections, workspace and e2e tests (1614) pass locally.