[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: wallet-core: fix DB migration
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: wallet-core: fix DB migration logic when only an index is added |
Date: |
Mon, 20 Feb 2023 15:14:41 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 85c5c6d7c wallet-core: fix DB migration logic when only an index is
added
85c5c6d7c is described below
commit 85c5c6d7c7304801fd223abea724fe67a56ff5fa
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Feb 20 15:07:30 2023 +0100
wallet-core: fix DB migration logic when only an index is added
---
packages/taler-wallet-core/src/db.ts | 48 ++++++++++++++++++------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index 7e1906351..a23ba0f76 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 = 4;
+export const WALLET_DB_MINOR_VERSION = 5;
/**
* Ranges for operation status fields.
@@ -2291,7 +2291,7 @@ export const WalletStoresV1 = {
"byExchangeAndContractPriv",
["exchangeBaseUrl", "contractPriv"],
{
- versionAdded: 4,
+ versionAdded: 5,
unique: true,
},
),
@@ -2299,7 +2299,7 @@ export const WalletStoresV1 = {
"byWithdrawalGroupId",
"withdrawalGroupId",
{
- versionAdded: 4,
+ versionAdded: 5,
},
),
byStatus: describeIndex("byStatus", "status"),
@@ -2319,7 +2319,7 @@ export const WalletStoresV1 = {
"byExchangeAndContractPriv",
["exchangeBaseUrl", "contractPriv"],
{
- versionAdded: 4,
+ versionAdded: 5,
unique: true,
},
),
@@ -2337,7 +2337,7 @@ export const WalletStoresV1 = {
"byWithdrawalGroupId",
"withdrawalGroupId",
{
- versionAdded: 4,
+ versionAdded: 5,
},
),
},
@@ -2663,28 +2663,28 @@ function upgradeFromStoreMap(
];
const storeDesc: StoreDescriptor<unknown> = swi.store;
const storeAddedVersion = storeDesc.versionAdded ?? 0;
- if (storeAddedVersion <= oldVersion) {
- continue;
- }
let s: IDBObjectStore;
- // Be tolerant if object store already exists.
- // Probably means somebody deployed without
- // adding the "addedInVersion" attribute.
- if (!upgradeTransaction.objectStoreNames.contains(swi.storeName)) {
- try {
- s = db.createObjectStore(swi.storeName, {
- autoIncrement: storeDesc.autoIncrement,
- keyPath: storeDesc.keyPath,
- });
- } catch (e) {
- const moreInfo = e instanceof Error ? ` Reason: ${e.message}` : "";
- throw Error(
- `Migration failed. Could not create store
${swi.storeName}.${moreInfo}`,
- );
+ if (storeAddedVersion > oldVersion) {
+ // Be tolerant if object store already exists.
+ // Probably means somebody deployed without
+ // adding the "addedInVersion" attribute.
+ if (!upgradeTransaction.objectStoreNames.contains(swi.storeName)) {
+ try {
+ s = db.createObjectStore(swi.storeName, {
+ autoIncrement: storeDesc.autoIncrement,
+ keyPath: storeDesc.keyPath,
+ });
+ } catch (e) {
+ const moreInfo = e instanceof Error ? ` Reason: ${e.message}` : "";
+ throw Error(
+ `Migration failed. Could not create store
${swi.storeName}.${moreInfo}`,
+ );
+ }
}
- } else {
- s = upgradeTransaction.objectStore(swi.storeName);
}
+
+ s = upgradeTransaction.objectStore(swi.storeName);
+
for (const indexName in swi.indexMap as any) {
const indexDesc: IndexDescriptor = swi.indexMap[indexName];
const indexAddedVersion = indexDesc.versionAdded ?? 0;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: wallet-core: fix DB migration logic when only an index is added,
gnunet <=