more information if migration failed, and pretty
This commit is contained in:
parent
473cbc3908
commit
72ca5ee8dd
@ -21,6 +21,7 @@ import {
|
||||
Event,
|
||||
IDBDatabase,
|
||||
IDBFactory,
|
||||
IDBObjectStore,
|
||||
IDBTransaction,
|
||||
} from "@gnu-taler/idb-bridge";
|
||||
import {
|
||||
@ -2477,20 +2478,35 @@ function upgradeFromStoreMap(
|
||||
if (storeAddedVersion <= oldVersion) {
|
||||
continue;
|
||||
}
|
||||
const s = db.createObjectStore(swi.storeName, {
|
||||
autoIncrement: storeDesc.autoIncrement,
|
||||
keyPath: storeDesc.keyPath,
|
||||
});
|
||||
let s: IDBObjectStore;
|
||||
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}`,
|
||||
);
|
||||
}
|
||||
for (const indexName in swi.indexMap as any) {
|
||||
const indexDesc: IndexDescriptor = swi.indexMap[indexName];
|
||||
const indexAddedVersion = indexDesc.versionAdded ?? 0;
|
||||
if (indexAddedVersion <= oldVersion) {
|
||||
continue;
|
||||
}
|
||||
s.createIndex(indexDesc.name, indexDesc.keyPath, {
|
||||
multiEntry: indexDesc.multiEntry,
|
||||
unique: indexDesc.unique,
|
||||
});
|
||||
try {
|
||||
s.createIndex(indexDesc.name, indexDesc.keyPath, {
|
||||
multiEntry: indexDesc.multiEntry,
|
||||
unique: indexDesc.unique,
|
||||
});
|
||||
} catch (e) {
|
||||
const moreInfo = e instanceof Error ? ` Reason: ${e.message}` : "";
|
||||
throw Error(
|
||||
`Migration failed. Could not create index ${indexDesc.name}/${indexDesc.keyPath}.${moreInfo}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -734,7 +734,6 @@ async function buildTransactionForPurchase(
|
||||
checkDbInvariant(!!timestamp);
|
||||
checkDbInvariant(!!purchaseRecord.payInfo);
|
||||
|
||||
|
||||
let status: ExtendedStatus;
|
||||
switch (purchaseRecord.purchaseStatus) {
|
||||
case PurchaseStatus.AbortingWithRefund:
|
||||
|
Loading…
Reference in New Issue
Block a user