docs: keep the existing database file when migrating to drift - #3862
Closed
onur-kesim wants to merge 1 commit into
Closed
onur-kesim wants to merge 1 commit into
onur-kesim wants to merge 1 commit into
Conversation
Fix two examples in the "Opening a drift database" section that claimed
to open "the same database" as the code above them, but used a
different file name ('db.sqlite' instead of 'demo.db').
Add a short paragraph and code sample for readers using drift_flutter
instead of a bare NativeDatabase: driftDatabase() names its database
file '$name.sqlite' under getApplicationDocumentsDirectory() by
default (drift_flutter/lib/src/native.dart), which is not the file
opened by the examples above it. Use DriftNativeOptions.databasePath
to point at the existing file instead (databasePath and
databaseDirectory are mutually exclusive, see
drift_flutter/lib/src/connect.dart).
Refs simolus3#3367
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
|
Thanks for the contribution! I have merged this in d9f88e5, the changes will be visible with the next drift release. |
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.
Refs #3367.
In "Opening a drift database", the guide says the drift snippets open the same database as the code above them, but the previous code opens
demo.dbwhile both drift snippets openeddb.sqlite. Following the guide literally opens a new, empty database instead of the existing one. Both are nowdemo.db.The second part is what #3367 asks for:
driftDatabase()stores<name>.sqliteundergetApplicationDocumentsDirectory()by default, so someone switching todrift_fluttersilently ends up on a different file. The new snippet passesdatabasePathto keep the existing one, and the text notes thatdatabasePathanddatabaseDirectoryare mutually exclusive.Documentation only. The two Dart snippets analyze cleanly against the
docspackage (drift, drift_flutter, path, path_provider). Thedrift_sqflitesnippet only changed its file name;drift_sqfliteis not a dependency of the docs package, so it cannot be analyzed there.On placement: in #3367 you wrote that you were not sure where to put this. The migration guide seemed like the natural home because it already maps old setups to drift, but I am happy to move it into the setup guide instead.