Skip to content

refactor(storage): split LocalDb into a schema and per-area repositories (#1502) - #1721

Merged
ZhuchkaTriplesix merged 4 commits into
devfrom
refactor/local-db-split
Oct 18, 2026
Merged

ZhuchkaTriplesix merged 4 commits into
devfrom
refactor/local-db-split

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1502

local_db.dart went from 1396 to 361 lines. LocalDb.instance keeps every public method with the same signature, so none of the ~190 importers change; it now delegates.

file what it holds
local_db_schema.dart LocalDbSchema: version, onCreate, onUpgrade (v1 to v13), the open pragmas, the profile id
local_db_models.dart ConnectionRow, SqlQueryHistoryEntry, MutationAuditEntry, McpActivityEntry, MutationAuditSource and the caps (re-exported from local_db.dart)
folder_repository.dart folders and the connection's folder
sql_query_history_repository.dart the history and its per-bucket pruning (the insert counters moved here)
activity_log_repository.dart mutation audit and MCP activity
app_settings_repository.dart key-value settings and ER layouts
connection_repository.dart connections with secrets and SSH config; tells the history repository when one is removed

Each repository takes the open-database function, so it runs on any Database, an in-memory one included. Method bodies were moved as they were. LocalDb keeps the open/close lifecycle, the file operations (path, backup, reset, WAL cleanup) and backupBeforeUpdate.

Tests: local_db_schema_test.dart creates 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.dart runs four repositories on an in-memory database without LocalDb. The existing storage, MCP, database, connections, workspace and e2e tests (1614) pass locally.

@github-actions github-actions Bot added storage Theme parser epic label: storage core Core library logic and services P2 Medium priority / Parity & Refactoring labels Oct 18, 2026
@github-actions github-actions Bot added this to the 0.5.0 milestone Oct 18, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 7869ce1 into dev Oct 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core library logic and services P2 Medium priority / Parity & Refactoring storage Theme parser epic label: storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant