-
-
Notifications
You must be signed in to change notification settings - Fork 461
Open
Description
Hi,
I have a use case where I am wanting to perform data migrations on data stored in the FlutterSecureStorage, but want to be able to do that in a single transaction, to reduce (or ideally eliminate), the possibility of the migration being interrupted and left in a bad state.
This would be something like a Future<void> writeAll(Map<String, String> data)
.
ideal:
log("Running migrations from ${previous.version} to ${current.version}");
var data = await storage.readAll();
for (final m in migrations) {
log("Running ${m.version}");
data = await m.migrate(data);
}
await storage.writeAll(data);
log("Migration complete!");
current:
log("Running migrations from ${previous.version} to ${current.version}");
var data = await storage.readAll();
for (final m in migrations) {
log("Running ${m.version}");
data = await m.migrate(data);
}
for (final e in data.entries) {
await storage.write(key: e.key, value: e.value);
// <--- possible interruption leaving partially updated application state
}
log("Migration complete!");
Thanks for the library and your work.
Metadata
Metadata
Assignees
Labels
No labels