aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/db.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-23 15:52:32 +0100
committerFlorian Dold <florian@dold.me>2023-02-23 15:52:32 +0100
commitdd9e4555baf3b98478e9ad2b0edf81ea81add5e2 (patch)
treeb3752c66dad17d10324080fac216c95f39a67871 /packages/taler-wallet-core/src/db.ts
parent339080e014e2a94cf93bb8ef8d5fbe6793ee4c48 (diff)
downloadwallet-core-dd9e4555baf3b98478e9ad2b0edf81ea81add5e2.tar.xz
wallet-core: fixup for legacy peer-push-debit transaction
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r--packages/taler-wallet-core/src/db.ts17
1 files changed, 15 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 29e97cd90..630713ee3 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -118,7 +118,7 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName";
* backwards-compatible way or object stores and indices
* are added.
*/
-export const WALLET_DB_MINOR_VERSION = 5;
+export const WALLET_DB_MINOR_VERSION = 6;
/**
* Ranges for operation status fields.
@@ -2606,6 +2606,17 @@ export const walletDbFixups: FixupDescription[] = [
});
},
},
+ {
+ name: "PeerPushPaymentInitiationRecord_ALL_removeLegacyTx",
+ async fn(tx): Promise<void> {
+ await tx.peerPushPaymentInitiations.iter().forEachAsync(async (pi) => {
+ // Remove legacy transactions that don't have the totalCost field yet.
+ if (!pi.totalCost) {
+ await tx.peerPushPaymentInitiations.delete(pi.pursePub);
+ }
+ });
+ },
+ },
];
const logger = new Logger("db.ts");
@@ -2613,11 +2624,13 @@ const logger = new Logger("db.ts");
export async function applyFixups(
db: DbAccess<typeof WalletStoresV1>,
): Promise<void> {
+ logger.trace("applying fixups");
await db.mktxAll().runReadWrite(async (tx) => {
for (const fixupInstruction of walletDbFixups) {
+ logger.trace(`checking fixup ${fixupInstruction.name}`);
const fixupRecord = await tx.fixups.get(fixupInstruction.name);
if (fixupRecord) {
- return;
+ continue;
}
logger.info(`applying DB fixup ${fixupInstruction.name}`);
await fixupInstruction.fn(tx);