Skip to content

Commit

Permalink
fix: only migrate if db version matches v3
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Mar 14, 2024
1 parent a8a0487 commit a64177a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const Map<String, Locale> SUPPORTED_LOCALES = {
"en": const Locale("en"),
// "es": const Locale("es"),
};
const int DB_VERSION = 3;
const String INSUFFICIENT_FUNDS_ERROR = "Insufficient funds";
const String APP_TITLE = "myWitWallet";
const String WINDOWS_FILE_NAME = "myWitWallet-windows.zip";
Expand Down
11 changes: 7 additions & 4 deletions lib/util/storage/database/database_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ class DatabaseService {
} else {
mode = DatabaseMode.create;
}
_dbService._database = await dbFactory
.openDatabase(_dbService._dbConfig!.path, version: 3, mode: mode,
onVersionChanged: (db, oldVersion, newVersion) async {
await migrateDB(db);
_dbService._database = await dbFactory.openDatabase(
_dbService._dbConfig!.path,
version: DB_VERSION,
mode: mode, onVersionChanged: (db, oldVersion, newVersion) async {
if (newVersion == DB_VERSION) {
await migrateDB(db);
}
});
}

Expand Down

0 comments on commit a64177a

Please sign in to comment.