added v6 migration skip and removed rowId field when rowId is undefined (otherwise autoincrement value won't work)

This commit is contained in:
Sebastian 2022-10-17 11:44:23 -03:00
parent 5e435ef343
commit d1f43ca5f2
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 10 additions and 7 deletions

View File

@ -193,6 +193,7 @@ export async function openTalerDatabase(
case "taler-wallet-main-v3":
case "taler-wallet-main-v4": // temporary, we might migrate v4 later
case "taler-wallet-main-v5":
case "taler-wallet-main-v6":
// We consider this a pre-release
// development version, no migration is done.
await metaDb

View File

@ -62,7 +62,9 @@ export async function provideBackupState(
};
await tx.config.put(backupStateEntry);
}
checkDbInvariant(backupStateEntry.key === ConfigRecordKey.WalletBackupState);
checkDbInvariant(
backupStateEntry.key === ConfigRecordKey.WalletBackupState,
);
return backupStateEntry.value;
});
}

View File

@ -674,13 +674,11 @@ export async function updateExchangeFromUrlHandler(
logger.warn(`exchange ${exchangeBaseUrl} no longer present`);
return;
}
let existingDetails = await getExchangeDetails(tx, r.baseUrl);
let acceptedTosEtag: string | undefined = undefined;
const existingDetails = await getExchangeDetails(tx, r.baseUrl);
if (!existingDetails) {
detailsPointerChanged = true;
}
if (existingDetails) {
acceptedTosEtag = existingDetails.tosAccepted?.etag;
if (existingDetails.masterPublicKey !== keysInfo.masterPublicKey) {
detailsPointerChanged = true;
}
@ -689,9 +687,8 @@ export async function updateExchangeFromUrlHandler(
}
// FIXME: We need to do some consistency checks!
}
let existingTosAccepted = existingDetails?.tosAccepted;
const newDetails = {
rowId: existingDetails?.rowId,
const existingTosAccepted = existingDetails?.tosAccepted;
const newDetails: ExchangeDetailsRecord = {
auditors: keysInfo.auditors,
currency: keysInfo.currency,
masterPublicKey: keysInfo.masterPublicKey,
@ -703,6 +700,9 @@ export async function updateExchangeFromUrlHandler(
tosCurrentEtag: tosDownload.tosEtag,
tosAccepted: existingTosAccepted,
};
if (existingDetails?.rowId) {
newDetails.rowId = existingDetails.rowId;
}
r.lastUpdate = TalerProtocolTimestamp.now();
r.nextUpdate = keysInfo.expiry;
// New denominations might be available.