refactor: clean database layer — DriftChatDatabase, v1 schema, InMemoryChatDatabase - #5
Merged
Merged
Conversation
Renames the Drift database implementation class and file to better communicate the underlying technology, and regenerates the .g.dart file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Promotes the in-memory ChatDatabase pattern to a first-class public API so consumers can use it in their own tests without depending on internal test helpers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nMemoryChatDatabase - Move `failed` to lowest rank in _statusOrder so it never overwrites read/delivered on dedup - Add _emitStarredMessages() helper, called from updateMessage when isStarred changes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the ~600-line FakeChatDatabase class from test_helpers.dart and replace all usages in test files with InMemoryChatDatabase from lib/testing.dart, which is now the canonical in-memory test double. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
databasePath now defaults to '' so tests and custom-database setups can omit it. ChatRegistry.createDatabase throws ArgumentError when the path is empty and no custom database is provided, making the misconfiguration explicit at runtime instead of silently failing deeper in Drift. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ePath Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
Cleans up the database layer that had accumulated migration history from previous project iterations and makes the database testable and replaceable.
ChatDatabaseImpl→DriftChatDatabaseand its file todrift_chat_database.dartfor clarityonUpgrademigration history (schemaVersion 1→8 had no live users)InMemoryChatDatabasefromlib/testing.dart— a full in-memoryChatDatabaseimplementation SDK consumers can use in their own tests without touching SQLiteFakeChatDatabasefrom internal test helpers, replaced byInMemoryChatDatabaseChatConfig.databasePathoptional (defaults to'') — no longer required when using a customChatDatabaseviaChatRegistry.custom(); throwsArgumentErrorif omitted when usingDriftChatDatabaseType of change
Testing
New
test/chat_registry_test.dartcovers:ChatConfig()constructs withoutdatabasePathdatabasePathdefaults to empty stringcreateDatabase()throwsArgumentErrorwhen path empty and no custom DBcreateDatabase()returns the custom DB when providedAll 146 tests pass.
Checklist
dart analyzepasses with no issuesflutter testpassesCHANGELOG.mdupdatedRelated issues