-
Notifications
You must be signed in to change notification settings - Fork 423
Migrate database if prefered option is available #3695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Migrate database if prefered option is available #3695
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this idea 🚀 I think we need an integration test for this as well (extras/integration_tests/web_wasm), but these are tricky to write. We could perhaps open a database with IndexedDB first and then pass this option to assert that data has been migrated to OPFS.
|
I agree, but I am having a lot of trouble running the tests localy, is there any setup you can point me to? The CONTRIBUTING.md does not have any information regarding this. |
|
If you run The basic layout of those tests is that we start a website making some functionality we want to call available as top-level JavaScript functions. The first argument is an optional parameter, the last argument is a completion callback. So you can call them with e.g. |
|
This is my log: PS F:\FlutterProjekt\drift\extras\integration_tests\web_wasm> dart test It seems like the daemon is not starting correctly, since MissingPortFile comes from build_daemon -> client.dart. |
|
Figured it out, there is this line of code: but my path ends with "\" Changing it to: Fixed that part at least ^^ |
|
I ran into another problem, the sqlite3.wasm file in the web folder just says ../../../../extras/assets/sqlite3.wasm which for some reason does not work for me. I replaced it with the file at the path and that seems to have fixed it. |
|
The only thing currently bothering me is that I dont clean up the "old" db after the move. I would need to add a completer to |
We could potentially move this into the worker? We'd have to expose the fact that we're initializing by moving another database over in
Doing that in the worker ensures we'll only delete old databases when the new one is ready. |
Created this PR to simplify migrating an existing Flutter app using Drift from one storage implementation to another.
The new implementation allows developers to specify a
preferredImplementation. If this implementation is available, the current database will be exported and used to initialize the new database via theinitializeDatabasefunction.This change should improve developer experience and make it easier to take advantage of the benefits of OPFS.