Replies: 7 comments
-
@kidusdev Well, I have reason to think that you want to put your SQLite database file into assets. But putting SQLite database file into assets will cause the data in the database to be lost after the user upgrades the App. There is no big problem in running migration at the entry point, and it should be optimized by the developer whether to run migration. This pattern design is just a simple demonstration of how to upgrade the database without losing data after the user upgrades the App. In addition, running migration at the entry point does not have much performance overhead, it only traverses assets and queries the records in the migration table. Usually, you should only make a database version lock file, such as writing a lockfile in the support directory, using it to indicate whether migration needs to be run. If so, the App homepage should display the data migration medium occupancy page. When the value of the lock file record is the situation that you judge that migration is not needed, you do not need to call the The reason why example is written in main is that it is just a simple demonstration of how to run migration. Of course, you also need to determine whether the database file exists. If it does not exist, you still need to run migration to create the database file. |
Beta Was this translation helpful? Give feedback.
-
@kidusdev I have reason to believe that we should find the best migration timing plan. At least most apps I have seen will determine whether migration is needed when using local databases and then jump to the upgrade prompt page. In addition, the engine design supports custom bundles, which means that dynamic migration plans can be implemented. For example, if there is a field error in the original migration, we cannot fix it by releasing a new version of the app, then we can use a remote http bundle to implement hot fixes for the database. |
Beta Was this translation helpful? Give feedback.
-
@medz, yeah you are right putting SQLite data into assets folder or running migration at the entry point might not be a good practice. but we can make migration in both ways
|
Beta Was this translation helpful? Give feedback.
-
This is a good idea, just check if it is a development environment at the entry point But there is a better solution, use Then add the SQLite database file to the assets, but making an
I think in this case, it is better to pack the SQLite database file directly on the remote end and include the data you need to update. Then directly replace the local database file. Because the purpose of A better solution I think is to delete the database file instead of But directly deleting the database and running migration is much more efficient than |
Beta Was this translation helpful? Give feedback.
-
In addition, I think it is best practice to store data locally on demand. Pulling all the data at once seems to be a very unreasonable design. |
Beta Was this translation helpful? Give feedback.
-
Shorebird this repository works on codepush for flutter apps its like hot restart in production when you update your code in your developement environment and verify it, the new code reaches all your users phones with out any playstore updates. they also use this architecture you can |
Beta Was this translation helpful? Give feedback.
-
@kidusdev It suddenly seems to me that what you want is a data migration solution, not a schema migration. |
Beta Was this translation helpful? Give feedback.
-
when we migrate prisma migration we migrate it like this
of course we can create new file that runs from command line like this
migration.dart
and run it in the cli using
dart run migration.dart
but it throws this error
Error: Dart library 'dart:ui' is not available on this platform.
dart run orm_flutter:migrate
lets gather ideas and implement it
Beta Was this translation helpful? Give feedback.
All reactions