mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
clean up db migrate
This commit is contained in:
parent
58deb850f2
commit
649ebd1987
2 changed files with 8 additions and 27 deletions
|
@ -36,7 +36,7 @@ abstract class Constants {
|
|||
// Enable Logger.print statements
|
||||
static const bool disableLogger = false;
|
||||
|
||||
static const int currentHiveDbVersion = 1;
|
||||
static const int currentHiveDbVersion = 2;
|
||||
|
||||
static List<int> possibleLengthsForCoin(Coin coin) {
|
||||
final List<int> values = [];
|
||||
|
|
|
@ -21,6 +21,10 @@ class DbVersionMigrator {
|
|||
FlutterSecureStorage(),
|
||||
),
|
||||
}) async {
|
||||
Logging.instance.log(
|
||||
"Running migrate fromVersion $fromVersion",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
switch (fromVersion) {
|
||||
case 0:
|
||||
await Hive.openBox<dynamic>(DB.boxNameAllWalletsData);
|
||||
|
@ -117,37 +121,14 @@ class DbVersionMigrator {
|
|||
return await migrate(1);
|
||||
|
||||
case 1:
|
||||
await Hive.openBox<dynamic>(DB.boxNameTrades);
|
||||
await Hive.openBox<dynamic>(DB.boxNameTradesV2);
|
||||
await Hive.openBox<ExchangeTransaction>(DB.boxNameTrades);
|
||||
await Hive.openBox<Trade>(DB.boxNameTradesV2);
|
||||
final trades =
|
||||
DB.instance.values<ExchangeTransaction>(boxName: DB.boxNameTrades);
|
||||
|
||||
for (final old in trades) {
|
||||
if (old.statusObject != null) {
|
||||
final trade = Trade(
|
||||
uuid: old.uuid,
|
||||
tradeId: old.id,
|
||||
rateType: "",
|
||||
direction: "direct",
|
||||
timestamp: old.date,
|
||||
updatedAt: DateTime.tryParse(old.statusObject?.updatedAt ?? "") ??
|
||||
old.date,
|
||||
payInCurrency: old.fromCurrency,
|
||||
payInAmount: old.statusObject!.expectedSendAmountDecimal,
|
||||
payInAddress: old.payinAddress,
|
||||
payInNetwork: "",
|
||||
payInExtraId: old.payinExtraId,
|
||||
payInTxid: "",
|
||||
payOutCurrency: old.toCurrency,
|
||||
payOutAmount: old.amount,
|
||||
payOutAddress: old.payoutAddress,
|
||||
payOutNetwork: "",
|
||||
payOutExtraId: old.payoutExtraId,
|
||||
payOutTxid: "",
|
||||
refundAddress: old.refundAddress,
|
||||
refundExtraId: old.refundExtraId,
|
||||
status: old.statusObject!.status.name,
|
||||
);
|
||||
final trade = Trade.fromExchangeTransaction(old);
|
||||
await DB.instance.put<Trade>(
|
||||
boxName: DB.boxNameTradesV2,
|
||||
key: trade.uuid,
|
||||
|
|
Loading…
Reference in a new issue