历程
一旦您的应用发布,它就会踏上一段奇妙的旅程,并可能接收令人兴奋的新功能,为您的用户带来益处。
在此过程中,您将需要运行一次性迁移来为这些令人兴奋的新功能做准备!
新功能!
此包可帮助您以增量方式运行一次性迁移,同时尽可能减少对应用程序启动时间的影响。
尽可能减少影响。
特点
运行增量迁移。
入门
要使用 Journey,您需要将此包包含在您的 pubspec 中
# pubspec.yaml
dependencies:
journey:
用法
为应用程序中的所有迁移创建迁移实现
class MigrateUserModelToHaveMultipleJourneys implements Migration {
String get id => "migrate_user_model_to_have_multiple_journeys";
@override
Future<MigrationResult> run() async {
// change the data model of your underlying data structure
return MigrationResult.successful;
}
}
class MigrateTokensToNativeSecureStorage implements Migration {
String get id => "migrate_tokens_to_native_secure_storage";
@override
Future<MigrationResult> run() async {
// read the tokens from the previous storage, and move them to the secure storage
return MigrationResult.successful;
}
}
定义完迁移后,定义历程
final journey = Journey(
migrations: [
MigrateUserModelToHaveMultipleJourneys(),
MigrateTokensToNativeSecureStorage(),
],
);
定义好历程后,在应用程序的适当时间执行迁移
// U can use the reports for analytical purposes
final reports = await journey.migrate();