idb does not detect that the array of objectstores has one more element and continues to run long :
i.e. if there has been a change, it does not detect anything and continues as if nothing has happened.
const objectStores = [
'refcom_1A_2017',
'refcom_1A_2018',
'refcom_1A_2019',
'refcom_1A_2021',
'refcom_1A_2022',
'refcom_1B_2017',
'refcom_1B_2018',
'refcom_1B_2019'
];
const idb = await openDB('Refcomn', 1, {
async upgrade(db, oldVersion, newVersion, transaction) {
console.log(oldVersion)
console.log(newVersion)
const objectStoreNames = Array.from(db.objectStoreNames);
for (const keyName of objectStoreNames) {
if (!objectStores.includes(keyName)) {
console.log(`Deleting object store ${keyName}`);
if (transaction && transaction.objectStore(keyName)) {
await transaction.objectStore(keyName).clear();
}
await db.deleteObjectStore(keyName);
}
}
for (const keyName of objectStores) {
if (!objectStoreNames.includes(keyName)) {
console.log(`Creating object store ${keyName}`);
db.createObjectStore(keyName);
}
}
},
blocked() {
console.log('This page is blocked by another open connection. Please close all tabs!');
}
});
Which change are you trying to detect? What does "continues to run long" mean? How does objectstores gain "one more element", and what is this element?
idb does not detect that the array of objectstores has one more element and continues to run long :
i.e. if there has been a change, it does not detect anything and continues as if nothing has happened.